tags:

views:

33

answers:

1

I don't see an option to checkout or list remote/local branches in this module

http://gitorious.org/git-python/

+3  A: 

After you’ve done

from git import Git
g = Git()

(and possibly some other command to init g to the repository you care about) all attribute requests on g are more or less transformed into a call of git attr *args.

Therefore:

g.checkout("mybranch")

should do what you want.

g.branch()

will list the branches. However, note that these are very low level commands and they will return the exact code that the git executables will return. Therefore, don’t expect a nice list. I’ll just be a string of several lines and with one line having an asterisk as the first character.

There might be some better way to do this in the library. In repo.py for example is a special active_branch command. You’ll have to go through the source a little and look for yourself.

Debilski
when i run r = Git.clone("git ...") r.checkout("develop") does not work.. AttributeError: 'str' object has no attribute 'checkout'
Mike
ok looks like I need to run a g = Git("dir") then I can checkout
Mike
Could be. I just cloned with `g` and then it worked.
Debilski