天天看點

git push報錯:The current branch master has no upstream branch問題解決

問題

進行

git push

操作時報錯:

fatal: The current branch master has no upstream branch.

git push報錯:The current branch master has no upstream branch問題解決

原因:沒有将本地的分支與遠端倉庫的分支進行關聯

通過

git branch

檢視本地分支隻有

master

git push報錯:The current branch master has no upstream branch問題解決

git branch -a

檢視遠端分支,有

master

remotes/origin/master

兩個

git push報錯:The current branch master has no upstream branch問題解決

這時由于遠端倉庫太多,且分支較多。在預設情況下,

git push

時一般會上傳到

origin

下的

master

分支上,然而當

repository

branch

過多,而又沒有設定關聯時,git就會産生疑問,因為它無法判斷你的push目标

解決

方式一

使用

git push --set-upstream origin master

指令

方式二

git push -u origin master