2016-12-31 118 views
4

我正在嘗試遵循一些步驟來貢獻GitHub上的存儲庫,並且其中一個步驟不起作用。步驟如下:https://github.com/wdbm/qTox/blob/master/CONTRIBUTING.md#how-to-open-a-pull-request如何解決Git錯誤「所請求的上游分支'上游/主'不存在」

我在GitHub上存放倉庫。

我克隆庫:

git clone https://github.com/<YOUR_USER>/qTox.git 

我訪問本地資源庫的目錄:

cd qTox 

我添加上游遠程以便能夠從上游儲存庫來獲取:

git remote add upstream https://github.com/qTox/qTox.git 

我嘗試將本地主分支指向上游存儲庫:

git branch master --set-upstream-to=upstream/master 

此命令失敗,出現以下錯誤信息:

error: the requested upstream branch 'upstream/master' does not exist 
hint: 
hint: If you are planning on basing your work on an upstream 
hint: branch that already exists at the remote, you may need to 
hint: run "git fetch" to retrieve it. 
hint: 
hint: If you are planning to push out a new local branch that 
hint: will track its remote counterpart, you may want to use 
hint: "git push -u" to set the upstream config as you push. 

我應該如何解決這個問題?我正在使用Git 2.9.3。

+2

你運行 「混帳取」,作爲提示說?還有,你在當地什麼分支? – zim

+0

@zim感謝您的建議。我試着運行'git fetch',但是當我運行'git branch master --set-upstream-to = upstream/master'時,我仍然得到相同的錯誤。我試圖按照[這裏]描述的步驟(https://github.com/wdbm/qTox/blob/master/CONTRIBUTING.md#how-to-open-a-pull-request)。 – d3pd

+1

你能顯示這兩個命令的輸出:「git status」和「git remote -v」嗎? – zim

回答

7

git fetch upstream master:master:這項工作only when you are not on master。 如果你在master,簡單的git fetch upstream就足夠了。

那麼您可以在本地master連接到遠程跟蹤分支upstream/master(剛剛被取出)

git branch -u upstream/master master 

然後你可以使用git pull更新master
同樣,如果你不在master,那麼是的,git fetch upstream master:master將工作。

-1

試試這個

git branch -u git branch --set-upstream-to=<remote>/<remote branch> branch 
相關問題