PyGit is a minimal implementation of Git in Python, capable of basic Git operations like committing and pushing to GitHub.
-
Initialize a new Git repository
-
Add files to the index
-
Commit changes with author and message
-
Push commits to a remote GitHub repository
-
Display the status of the working copy
-
Show differences between index and working copy
-
Other basic Git functionalities
No installation is required. Just clone this repository and run the script directly.
PyGit is a command-line tool and can be used with various commands similar to Git:
python pygit.py [options]
-
init <repo>
: Initialize a new repository. -
add <paths>
: Add file(s) to the index. -
commit -m <message> [-a <author>]
: Commit the current state of the index to the master branch. -
push <git_url> [-u <username>] [-p <password>]
: Push the master branch to the given Git server URL. -
status
: Show the status of the working copy. -
diff
: Show the diff of files changed between the index and the working copy. -
cat-file <mode> <hash_prefix>
: Display contents of the object. -
ls-files [-s]
: List files in the index. -
hash-object <path> [-t <type>] [-w]
: Hash the contents of the given path.
- Initialize a new repository:
python pygit.py init my_repo
-
Add a file to the index:
python pygit.py add my_file.txt
- Commit changes:
python pygit.py commit -m "Initial commit"
- Push to remote:
python pygit.py push https://github.com/username/repo.git
PyGit is written in Python and requires no external dependencies. It uses standard libraries available in Python.
PyGit is released under the MIT License. See LICENSE.txt for more details.
Contributions to PyGit are welcome! Please read the contributing guidelines before submitting pull requests.
Thanks to Ben Hoyt for the inspiration and guidance through his writings on implementing Git in Python.
This README is a brief overview of PyGit. For more detailed information, refer to the source code and comments within it.