2013-10-21 70 views
1

如何以下命令:混帳配置: 「remote.origin.push」 與 「push.default」

git config remote.origin.push refs/heads/master:refs/heads/master 

涉及以下命令:

git config push.default <option> 

(或者與--local--global選項)

其中<option>是下列之一:

nothing 
matching 
upstream (formerly tracking) 
current 
simple 

我想我明白了第二個配置命令,但我不明白第一個命令條件/如何與第二個命令相關。這裏有一些參考的是提供上下文這背後的問題:

回答

5

當你運行:

git push origin ... 

無論是設置在remote.origin.push覆蓋任何設置在push.default。更一般地說,如果沒有設置remote.name.push(這裏的nameorigin),那麼git會回退到push.default,然後如果還沒有設置,它將回退到鏈接中描述的內置默認值。

需要注意的是:

git config --local na.me value 

意味着同樣的事情,因爲沒有--local。當設置值(如此處)時,--local--global--file filename選項控制設置值的位置,但默認爲--local

(當取值:

git config na.me 

[或git config --getgit config --get-allgit config --get-regexp]時,--local等,選擇限制其中git會從讀出,在沒有一個從他們的所有讀取如果在多個地方設置了「最本地」覆蓋「較不本地」)。

+0

謝謝! - 當你說'git push origin ...','...'是分支名稱(如果提供的話),是正確的? –

+1

是(或任意refspecs,例如'refs/tags/foo',':refs/deleteme'等)。 – torek