2013-05-06 140 views
1

我在GIT中下面的遙控器:無法推到輔助遠程

origin file:///some_path/project/ (fetch) 
origin file:///some_path/project/ (push) 
release file:///some_other_path/project/ (fetch) 
release file:///some_other_path/project/ (push) 

和我稱:

git push --set-upstream origin --all 
git remote update 

當我推到origin

git push origin

一切正常,但是當我嘗試推送到release時:

git push release

我得到以下錯誤:

fatal: You are pushing to remote 'release', which is not the upstream of 
your current branch 'master', without telling me what to push 
to update which remote branch. 

爲什麼?

回答

3

master分支有一個指示器,它的遙控器是origin/master。您可以通過git config -l看到:

branch.master.remote=origin 
branch.master.merge=refs/heads/master 

這樣,git push知道,到遠程分支應該把你的變化,而無需顯式指定它。

嘗試在推送到release時指定遠程分支:git push release master

+0

你說得對。嗯,所以我認爲沒有辦法預先指定每個遠程的默認推送分支? – 2013-05-06 22:35:00

+0

有一種方法可以指定分支的默認遠程引用。你已經通過'--set-upstream origin --all'完成了這項工作。但是,如@sleske所示,還有一個'push.default'配置參數,它指定推送所有遠程存儲庫的默認分支。 – harpun 2013-05-06 22:40:26

2

您需要告訴git push您要推送哪個分支,以及它應該放在哪裏。

有兩種方法來實現:

  • 明確:你可以明確地告訴git push如何通過使用完整的語法git push <repository> <refspec>做。 「refspec」通常是<local branch>:<remote branch>的形式。所以在你的情況下,git push release master:master會將你的本地主人推送到「發佈」的主分支。
  • 含蓄地:如果你總是想將當前分支推送到遠程倉庫中的同名分支,你可以告訴git。爲此,請設置pref「push.default = current」(git config --local push.default current)。然後git push release將工作,並將本地主人推到遠程主人。

至於爲什麼它不適用於你的情況:它看起來像你在你的配置中設置「push.default = simple」(或「upstream」)。然後git會希望你推到一個分支的上游,否則就會抱怨。