How to override Git config options by command line

2019-01-18 01:42发布

I want to override certain Git config options (in my case http.proxy) when calling a Git command directly by using command line parameters. Is this possible?

标签: git config
2条回答
▲ chillily
2楼-- · 2019-01-18 02:10

Note that there is a new feature regarding the ability to override (with the command git -c) a config:

You couldn't set a config to an empty string (git -c http.proxy= or any other foo.bar=), that is until git 2.1.2 (Sept 30th, 2014), and commit a789ca7 Junio C Hamano (gitster)

config: teach "git -c" to recognize an empty string

In a config file, you can do:

[foo]
bar

to turn the "foo.bar" boolean flag on, and you can do:

[foo]
bar=

to set "foo.bar" to the empty string.
However, git's "-c" parameter treats both:

git -c foo.bar

and

git -c foo.bar=

as the boolean flag, and there is no way to set a variable to the empty string.
This patch enables the latter form to do that.

查看更多
够拽才男人
3楼-- · 2019-01-18 02:16

Yes, you can pass it with -c, like:

git -c http.proxy=someproxy clone https://github.com/user/repo.git
查看更多
登录 后发表回答