I have multiple lab machines and I need to make a copy of my remote branch on my local lab machine. I believe the git bash command for this is:
git checkout -b mybranch origin/mybranch
How do I do the equivalent in GitPython?
I may make changes and push the changes back to origin/mybranch and then pull the changes back on to other lab machines.
1 Answer 1
From a quick look at their docs, it looks like you should be able to do git.checkout('origin/mybranch', b='mybranch'). I'm not very familiar with GitPython though, so take that with a grain of salt.
answered Aug 28, 2012 at 18:22
jdd
4,3461 gold badge29 silver badges28 bronze badges
Sign up to request clarification or add additional context in comments.
4 Comments
Jon Boehm
Yes I saw that. I couldn't get it to work. In the following example I know that the 'staging' branch exists on the remote repo. >>? from git import * >>? repo = Repo(r'C:\Projects\TestRepo4') >>? git = repo.git >>? git.checkout('origin/staging', b='staging') WindowsError: [Error 2] The system cannot find the file specified >>? git.checkout('remotes/origin/staging', b='staging') WindowsError: [Error 2] The system cannot find the file specified
jdd
What version of GitPython are you using?
jdd
Does doing
repo.remotes.origin.fetch() prior to attempting the checkout have any effect?Jon Boehm
Solved the problem. The windows git installer must not add "C:\Program Files (x86)\Git\bin" to the path.