发现问题
本地新建了一个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
根据提示的命令git push --set-upstream origin dev
,这条命令是将远程也重新创建一个分支dev,这样就匹配了,然后再push
执行完毕后,远程就会多出一个dev分支,并且我的代码也更新在了上面文章来源:https://www.toymoban.com/news/detail-506301.html
方法2
指定分支push文章来源地址https://www.toymoban.com/news/detail-506301.html
到了这里,关于【git报错】The current branch dev has no upstream branch. To push the current branch and set the remote的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!