Simple git wrapper for python
Project description
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 gyt 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'')
- NOTE: If you don't have configured the path of the git binary in your path. Execute the next command:
-
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for python-git-wrapper-0.9.0.post1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 182840c8716d2d756f95abfeea3ff04fdef429dba8a62034fe5cdc396fa62794 |
|
MD5 | b588734abd9f2cd9b0cb08fd7096e3c9 |
|
BLAKE2b-256 | 9c1ad260c27bed2bf573a2ebec838bc45d12397c6308540ad82971814c039ab6 |
Hashes for python_git_wrapper-0.9.0.post1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 644fbd0c6bc146a3abdb430189607a544dfa91867def389968f3c45b846916c5 |
|
MD5 | 6ac0b89e5fc267f704920051894c0f7e |
|
BLAKE2b-256 | 3ae773d1e3935c8cf2cb2fc5af68194c79a33f894e9b234a9b16d54f359a8f78 |