【git报错】The current branch dev has no upstream branch. To push the current branch and set the remote

这篇具有很好参考价值的文章主要介绍了【git报错】The current branch dev has no upstream branch. To push the current branch and set the remote。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

发现问题

本地新建了一个dev分支,然后把dev分支下的代码push到远程仓库中,使用git push,但是报错了,如下:
【git报错】The current branch dev has no upstream branch. To push the current branch and set the remote
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分支,并且我的代码也更新在了上面

方法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模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • fatal: The current branch master has no upstream branch之解决方法

            本地通过Git下载代码后进行了修改,在推送至远程仓库时缺少目标仓库地址 3.1 本地客户端远程连接目标仓库  git remote add origin https://github.com/**/*.git【自己的SSH】 3.2 推送本地代码至远程仓库分支 git push -u origin master         以上操作是在本地已经执行 add 及

    2024年02月15日
    浏览(39)
  • git 新建分支 推送到远程 首次pull代码报错 git branch --set-upstream-to=origin/<branch>

    在本地创建新分支后,上传到远程仓库,首次pull 的时候,会提示: 当前分支与远程分支并未建立联系,需要执行一下 git branch --set-upstream-to=origin/ 操作 解决办法: git branch --set-upstream-to=origin/远程分支名 建立完联系之后,就可以进行 git pull、git push 等操作啦~

    2024年02月16日
    浏览(42)
  • Git 分支跟踪There is no tracking information for the current branch.

    当你执行在develop分支上 git pull 返回提示: 解决办法,即按照提示: 查看本地分支的远端跟踪分支 要查看本地分支跟踪的远端分支,可以使用 git branch 命令搭配不同的选项。以下是一些常用的命令及其说明: 查看所有本地分支及对应的远端跟踪分支: 使用 -vv 选项可以显示

    2024年02月21日
    浏览(38)
  • Git出现There is no tracking information for the current branch提示的解决办法

    Git出现There is no tracking information for the current branch提示的解决办法 使用命令新建分支并切换到该分支 从远程获取代码 报错 There is no tracking information for the current branch. Please specify which branch you want to merge with. 意思是没有当前分支的追踪信息 解决: 以上两行命令可简写为 即将本

    2024年02月12日
    浏览(39)
  • git 出现 There is no tracking information for the current branch. Please specify which branch you want

    问题分析:当前pull对象没有远程分支的跟踪信息,简单地来说就是你创建的这个分支没有和远程仓库中的其他分支或者master建立联系,所以导致当前分支无法进行pull操作; 解决方案: git branch --set-upstream-to=origin/remote_name local_name 注解: remote_name : 远程分支名 // 这里是你创

    2024年02月05日
    浏览(37)
  • git报错:Updates were rejected because the tip of your current branch is behind

    多人协作项目,其他成员提交之后,你这边没有拉取最近代码就要进行推送,远程仓库和本地仓库不同步。 一般远程仓库和本地仓库是同步的,当有另一个人克隆远程仓库并修改推送代码后,你这边的本地仓库再进行推送会提示这个错误。“更新被拒绝,因为您当前分支的提

    2024年02月15日
    浏览(48)
  • Can‘t update dev_zgd has no tracked branch

    今天使用 Pycharm 时,本地在 dev 分支上,点击 VCS 更新按钮出现如下错误: 怎么解决呢? 输入以下命令: 来设置分支主机以跟踪远程分支主机 试着更新一下,结果如下: Git更新,出现Can’t update: no tracked branch错误

    2024年02月13日
    浏览(32)
  • Git问题:出现报错-You are not allowed to push code to protected branches on this project

    Git问题:出现报错-You are not allowed to push code to protected branches on this project 最近不是在做数据安全分类分级的项目吗,所以在公司的gitLab上新创建了一个 空白项目 ,但是在本地创建分支后提交到远程时出来问题。 执行提交 git push 的时候, 提示如下图 然后跟随提示执行了下面

    2024年02月02日
    浏览(42)
  • git reset current branch to here

    reset current branch to here是git命令中的一种回滚操作。 其使用场景如下, 1)提交了多次错误的提交,想回滚到之前的某次提交。 2)合并了错误的分支,想回滚到合并之前。 该操作回滚到某次commit提交后,该commit提交之后提交的代码都可以再次修改重新提交。 另外,还有一种

    2024年01月19日
    浏览(36)
  • 多种方法解决There is no tracking information for the current branch的错误

    今天发布某版本的项目,准备创建个 v0point1 分支,后期如果修改该版本,直接在该分支上修改即可。 首先,使用 git branch v0point1 命令,创建本地分支 v0point1 ,如下图所示: 其次,使用 git checkout v0point1 命令,切换到 v0point1 分支,如下图所示: 当然,我们也可以使用 git ch

    2024年02月09日
    浏览(37)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包