I am trying to find the way to pull a git repository using gitPython. So far this is what I have taken from the official docs here.
test_remote = repo.create_remote('test', 'git@server:repo.git') repo.delete_remote(test_remote) # create and delete remotes origin = repo.remotes.origin # get default remote by name origin.refs # local remote references o = origin.rename('new_origin') # rename remotes o.fetch() # fetch, pull and push from and to the remote o.pull() o.push()
The fact is that I want to access the repo.remotes.origin to do a pull withouth renaming it's origin (origin.rename) How can I achieve this? Thanks.
The content of the multiple remote repositories can be pulled to the local drive by using the command, `git pull origin` or `git pull upstream`.
You can view that origin with the command git remote -v, which will list the URL of the remote repo.
Getting The Remote URL For a Git Repository If you're unsure what the remote is called, simply run “ git remote ,” which will print all of them.
The git pull command is used to fetch and download content from a remote repository and immediately update the local repository to match that content. Merging remote upstream changes into your local repository is a common task in Git-based collaboration work flows.
I managed this by getting the repo name directly:
repo = git.Repo('repo_path') o = repo.remotes.origin o.pull()
Hope you are looking for this :
import git g = git.Git('git-repo') g.pull('origin','branch-name')
Pulls latest commits for the given repository and branch.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With