發(fā)現(xiàn)問題
本地新建了一個dev分支,然后把dev分支下的代碼push到遠程倉庫中,使用git push,但是報錯了,如下:
fatal: The current branch dev has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin dev
翻譯
錯誤:當前分支:dev沒有遠程對應的dev分支。
要推動當前分支并將遠程設置為上游,請使用。。。
原因
首先git push
命令,是默認將當前分支Push到遠程的對應的分支,如果遠程不存在對應分支,則會報錯。比如這里,本地是dev分支,遠程沒有dev分支,使用這條命令默認就是對應遠程dev分支,所以就會報錯。
解決方法
方法1
根據(jù)提示的命令git push --set-upstream origin dev
,這條命令是將遠程也重新創(chuàng)建一個分支dev,這樣就匹配了,然后再push
執(zhí)行完畢后,遠程就會多出一個dev分支,并且我的代碼也更新在了上面文章來源:http://www.zghlxwxcb.cn/news/detail-506301.html
方法2
指定分支push文章來源地址http://www.zghlxwxcb.cn/news/detail-506301.html
到了這里,關于【git報錯】The current branch dev has no upstream branch. To push the current branch and set the remote的文章就介紹完了。如果您還想了解更多內容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!