-
When trying to execute any command by using the execute() method (e.g.
Is this a bug? |
Beta Was this translation helpful? Give feedback.
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. |
Beta Was this translation helpful? Give feedback.
-
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? |
Beta Was this translation helpful? Give feedback.
-
You can manually instantiate a |
Beta Was this translation helpful? Give feedback.
-
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 |
Beta Was this translation helpful? Give feedback.
-
g = Git( git_dir )
rval = g.config(…)
|
Beta Was this translation helpful? Give feedback.
-
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
|
Beta Was this translation helpful? Give feedback.
git_dir
can 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.