I am trying to use git-python to add, commit and push to a repository. Following the incomplete documentation and an example here I tried it the following way:
myrepo = Repo('Repos/hello-world/.git')
# make changes to README.md
myrepo.index.add('README.md')
myrepo.index.commit("Updating copyright year")
myrepo.git.push("origin", "copyright_updater") ###
I checked out the repository hello_world
and put it under a folder Repos
. I did change a single file, the README.md
. But with that code I get an error
git.exc.GitCommandError: Cmd('git') failed due to: exit code(1)
cmdline: git push origin copyright_updater
stderr: 'error: src refspec copyright_updater does not match any.
error: failed to push some refs to '[email protected]:alex4200/hello-world.git''
in the marked line.
How can I fix it, in order to push the changes to a new branch and to create a pull request on GitHub?