Skip to main content

Git Wrapper

The Simple Python Git Wrapper

This library is a simple git wrapper which let you perform many operations on any git repository in a powerful and simple way.

Requirements

This library has been tested python >= 3.7, 3.8 and you need to have installed Git > 2.22.0

Getting Started

The library is pretty simple, you only need to indicate where your repository is or create a new one.

from python_git_wrapper import Repository

repository = Repository('.') # Path of your git repository. It could be relative to your project or absolute

Or if the repository doesn't exist yet

repository = Repository('.', create=True)

Adding files:

repository.add_files('path to any file')

Committing changes:

repository.commit('commit message')

Finally, pushing them:

repository.push()

Components

The library is divided in 3 main components.

  • Git Service: Object which contains all the data to communicate with the git process properly.

    • NOTE: If you don't have configured the path of the git binary in your path. Execute the next command: GitService.singleton('git path'')
  • Repository: It will be your entry point, which you will interact to provide an retrieve all the information. It is a reference to the repository you want to work on.

  • Git Elements:

    • Commit: Containing all the relevant information about any commit

    • Branch: Contains the name of the branch

    • Status: Object which structure all the changes in your working directory

API Overview

Small overview about the capabilities of this library. All this methods and attributes are accesible by the repository object.

Method Description Return
build Create or init a new git repository Repository
commit Commit the staged changes Status
status Retrieve the Status of the Working Directory Status
push Push Changes to remote repository Status
pull Pull changes to remote repository Status
checkout Change HEAD reference Status
create_branch Create a new branch, go there if necessary Branch
merge_branches Merge two branches. Support different merge modes Branch
add_remote Add a new remote repository Status
remove_remote Remove a remote repository Status
execute execute any git command in the repository str
revert_last_commit Generate a new commit reverting the previous one Commit
change_last_commit_message Rewrite the previous commit message Commit
get_commit_by_position Retrieve Commit by position in the current branch Commit
get_branches_by_commit Retrieve all the branches which contain one specific commit Commit
Property Description Return
branches List of your local branches List[Branch]
current_branch The branch where it is currently the repository Branch
remote List of your remote repository names List[str]
last_commit The last commit in your repository Commit

Detailed API Specification Here.

Metadata

Release files for python-git-wrapper 0.9.0.post2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python-git-wrapper 0.9.0.post2
File Size Uploaded
python-git-wrapper-0.9.0.post2.tar.gz 9.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for python-git-wrapper 0.9.0.post2
File Interpreter ABI Platform
python_git_wrapper-0.9.0.post2-py3-none-any.whl Python 3 none any Details

Total release size: 21.6 kB

Release files / python-git-wrapper-0.9.0.post2.tar.gz

Download URL python-git-wrapper-0.9.0.post2.tar.gz
Size 9.1 kB
Tags Source
SHA-256 checksum
How to use checksums
7b347422a27188825b60627d8d0c35be08bf9eeaafb319e597cb8c1e46220a26
BLAKE2b-256 checksum
How to use checksums
f0087a815a72aae2852ff0bdb3b097a7903ba7c509f6a8830aed5f83fe5c8b3c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.0

Release files / python_git_wrapper-0.9.0.post2-py3-none-any.whl

Download URL python_git_wrapper-0.9.0.post2-py3-none-any.whl
Size 12.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f8576e127a57904666ac5405bd5abdd391e4d88765ac4a86002f9de61d02af2d
BLAKE2b-256 checksum
How to use checksums
c45d11e5504a699773c424443275781b087e2d9ce6239558a84655b019977759
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.0

Release history Release notifications | RSS feed

This release

0.9.0.post2 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page