在git-python中签出/列出远程分支 [英] Checkout/List remote branches in git-python
问题描述
我没有看到在本模块中签出或列出远程/本地分支的选项。
I don't see an option to checkout or list remote/local branches in this module
http://gitorious.org/git-python/
推荐答案
完成之后
from git import Git
g = Git()
(可能还有其他一些命令用于初始化 g
) g
上的所有属性请求或多或少地转换为 git attr * args
的调用。
(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()
会列出分支。但是,请注意,这些命令的级别非常低,它们将返回git可执行文件将返回的确切代码。因此,不要指望一个好的列表。我只是一个由几行组成的字符串,其中一行用星号作为第一个字符。
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.
在库中可能有一些更好的方法。例如, repo.py
是一个特殊的 active_branch
命令。你必须经过一些源代码并寻找自己。
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.
这篇关于在git-python中签出/列出远程分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!