2014-09-28 47 views
0

我想設置一個git別名來快速配置我的user.nameuser.emailgit別名中的多個git配置

我試圖與--add選擇玩,但我不能做這樣的事情:

[alias] 
    cfTest = config --add user.email "[email protected]" --add user.name "test" 

我得到的是:

error: wrong number of arguments 

我想用git做別名,但如果不可能,我會用普通的bash別名來做。

你會怎麼做?

+0

對'--add'標誌的描述如下:*在選項中添加一個新行而不更改任何現有值。這與在'--replace-all' *中提供'^ $'作爲value_regex相同。我不認爲這就是你想要的。 – Jubobs 2014-09-28 17:38:38

回答

1

您不能將-add選項多次傳遞給單個git config命令,您需要撥打git config兩次。

[aliasl] 
    cfgTest = !git config user.name "Andy" && git config user.email "[email protected]" 
+0

'[aliasl]'?這是一個錯字嗎? – Jubobs 2014-09-28 17:44:33

+0

非常好,謝謝=)你是怎麼找到這個的?提醒我一個vim':!'bash命令 – nobe4 2014-09-28 17:44:36

+0

https://www.kernel.org/pub/software/scm/git/docs/git-config.html - 「如果別名擴展前面帶有感嘆號,它將被視爲shell命令「 – 2014-09-28 17:54:19