I have two repositories on github, using gitpython I'm trying to push a file from one repository to another remote repository. I've managed to do it using git but struggling with the gitpython code.
git remote add remote_to_push git@bitbucket...
git fetch remote_to_push
git checkout remote_to_push/master
git add file_to_push
git commit -m "pushing file"
git push remote_to_push HEAD:master
I've managed to create a repo object of the remote I think with the following
from git import Repo
repo = Repo('path/to/other/git/repo')
remote = repo.remotes.origin
I can't figure out how to add something to then push, if i call
remote.add("file_to_push")
Then I get errors about the create() function
TypeError: create() takes exactly 4 arguments (2 given)
Trying to follow what they have done in How to push to remote repo with GitPython with
remote.push(refspec='{}:{}'.format(local_branch, remote_branch))
I assume it should work with using master and master as the remote branches as they both must exist but it's giving me the error
stderr: 'error: src refspec master does not match any.'
Thanks