2014-09-21 106 views
4

有上如何改變push命令的參數,使處理來避免這個消息的相關問題:如何禁止「致命的:當前分支的上游分支與當前分支的名稱不匹配」?

fatal: The upstream branch of your current branch does not match the name of your current branch

我感興趣的是如何壓制消息本身,沒有改變我的本地/遠程分支的名稱或使用花式push命令。

假設我有一個本地分支跟蹤不同名稱的遠程分支:

[email protected]:~ git branch -vv 
branch-name abcd1234 [remote/origin/branch-name] last commit message 

現在我希望能夠通過簡單地鍵入git push推我COMMITED變化。當我這樣做,我得到以下信息:

fatal: The upstream branch of your current branch does not match 
the name of your current branch. To push to the upstream branch 
on the remote, use 

    git push origin HEAD:remote/origin/branch-name 

To push to the branch of the same name on the remote, use 

    git push origin branch-name 

如何強制git自動推到上游分支,即使名稱不匹配?我使用git 1.9.1

回答

9

較新的Git(V 1.9或更新版本)

git config --global push.default upstream 

年長的Git

git config --global push.default tracking 

的Git 2.3仍然接受tracking作爲上游

的代名詞只是做一旦你「git push」,它會將當前分支推送到它配置的上游。

這也將其設置在您的全局配置中,這可能會被存儲庫配置中的不同設置所遮蔽。

+0

謝謝安德魯,我進入那個命令,然後鍵入'git push'並得到相同的消息。 – arman 2014-09-21 22:52:21

+0

查看存儲庫.git/config文件或系統中是否存在衝突的設置/ etc/gitconfig – 2014-09-21 22:56:52

+0

tracking最好似乎是可疑的:列出的5個可能值是'current','matching', 'nothing','simple'和'upstream'。在這種情況下,「上游」似乎是最有可能的期望之一。跟蹤和上游的 – torek 2014-09-22 00:32:35

相關問題