2

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

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.

Sign up to request clarification or add additional context in comments.

4 Comments

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
What version of GitPython are you using?
Does doing repo.remotes.origin.fetch() prior to attempting the checkout have any effect?
Solved the problem. The windows git installer must not add "C:\Program Files (x86)\Git\bin" to the path.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.