|
When trying to execute any command by using the execute() method (e.g.
Is this a bug? |
Replies: 6 comments
|
I recommend reading the docs on how to use git directly to resolve this issue. The problem is trying to use an instance method as a class method. |
Thanks Byron for pointing me the doc. So if I have to change the git global config, there's nothing I can do, am I correct? |
|
You can manually instantiate a |
I was searching a way to manage the git config --global without having a repo setup. In particular, before cloning a repo I need to ensure that the global proxy settings are correctly placed in the config list ( A workaround could be to initialize a dummy empty repo which I can use to execute the global config commands, and then delete it. But it's a dirty solution... Do you have better ideas? Thanks in advance |
g = Git( git_dir )
rval = g.config(…)
|
|
This example is too short, I re-written an example, hope it helps. from git import Git
def update_force(path):
"""
强制更新
"""
g = Git(path)
g.config("--global", "http.proxy", "socks5://127.0.0.1:10808")
g.checkout('*')
pull_info = g.pull("--no-rebase")
g.config("--global", "--unset", "http.proxy")
info = g.for_each_ref()
return info
|
git_dircan be any existing directory, it is the working directory of the git command when spawned. This doesn't need to be a repository.Maybe try it with the invocation you need.