git push報(bào)錯(cuò):The current branch master has no upstream branch

原文鏈接:https://blog.csdn.net/tian_ci/article/details/93397137

問題

進(jìn)行g(shù)it push操作時(shí)報(bào)錯(cuò):fatal: The current branch master has no upstream branch.

**原因:**沒有將本地的分支與遠(yuǎn)程倉庫的分支進(jìn)行關(guān)聯(lián)

通過git branch查看本地分支只有master

通過git branch -a查看遠(yuǎn)程分支,有master和remotes/origin/master兩個(gè)

這時(shí)由于遠(yuǎn)程倉庫太多,且分支較多。在默認(rèn)情況下,git push時(shí)一般會上傳到origin下的master分支上,然而當(dāng)repository和branch過多,而又沒有設(shè)置關(guān)聯(lián)時(shí),git就會產(chǎn)生疑問,因?yàn)樗鼰o法判斷你的push目標(biāo)

解決

方式一

使用git push --set-upstream origin master命令

方式二

使用git push -u origin master命令

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

友情鏈接更多精彩內(nèi)容