I'm trying to automate a change process which currently creates source code that gets manually pushed to Git. I'm trying to wrap that code using GitPython:
from git import *
# create the local repo
repo = Repo.init("/tmp/test/repo", bare=True)
assert repo.bare == True
# check status of active branch
# clone the remote repo
remote_repo = repo.clone("http://user:[email protected]/repo.git")
# compile source code into repository
# track untracked files
# commit changes locally
# push changes to master
Traceback (most recent call last):
File "git_test2.py", line 33, in
Some of the functions you are using may not work the way you expect them to. Generally,
Repo methods are not the equivalent of the
git sub-command with the same name.
Repo.commit does not create a commit but retrieve an existing commit. Since there is not commit named “commit changes” in the repository, an exception is raised.
Repo.clone creates a clone of this repository in a directory called
http: inside the repository's directory structure which is most probably not what you want.
If you are trying to clone a remote repository, this can be achieved in a single line:
repo = Repo.clone_from("http://user:[email protected]/repo.git", "/tmp/test/repo")
See the API Reference for more information on how to use GitPython.