how to pull, push with remote branch
git, git-pull, git-push, gitpython, python
Solution
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:pass@git/repo.git", "/tmp/test/repo")
See the API Reference for more information on how to use GitPython.
Problem
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 repo.is_dirty() # clone the remote repo remote_repo = repo.clone("http://user:pass@git/repo.git") # compile source code into repository # ... # track untracked files repo.untracked_files # commit changes locally repo.commit("commit changes") # push changes to master remote_repo.push() ``` When I try running this, I get Traceback (most recent call last): File "git_test2.py", line 33, in repo.commit("commit changes") BadObject: 636f6d6d6974206368616e676573 The script is able to pull the remote repository, but fails on commit. Is there a better approach to this?