git 无法push远程仓库 Note about fast-forwards 问题解决

git push 远程仓库时,出现以下类似错误,'Note about fast-forwards' in 'git push --help' for details.

To https://github.com/SeshinWei/django.git

! [rejected] master -> master (non-fast-forward)

error: failed to push some refs to 'https://github.com/SeshinWei/django.git'

hint: Updates were rejected because the tip of your current branch is behind

hint: its remote counterpart. Integrate the remote changes (e.g.

hint: 'git pull ...') before pushing again.

hint: See the 'Note about fast-forwards' in 'git push --help' for details.

错误:non-fast-forward
远程仓库:origin
远程分支:master
本地分支:master

完整报错代码可能是这样的:

There is no tracking information for the current branch.

Please specify which branch you want to merge with.

See git-pull(1) for details.

git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

git branch --set-upstream-to=origin/<branch> master

原因是没有指定本地 master 分支和远程 origin/master 的连接,这里根据提示:

git branch --set-upstream-to=origin/master master

 解决方案:因为远程仓库新建时,有LIENCE,由于本地仓库和远程仓库有不同的开始点,也就是两个仓库没有共同的commit出现,无法提交,此时我们需要allow-unrelated-histories。也就是我们的 pull 命令改为下面这样的:

git pull origin master --allow-unrelated-histories

如果设置了默认分支,可以这样写:

git pull --allow-unrelated-histories

然后 git push 就可以了。

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
See the 'Note about fast-forwards' in 'git push --help' for details是在git push命令的帮助文档中提到的一条注意事项。[1] 这个提示是关于在使用git push命令时可能出现的一种错误情况,即推送失败,提示"non-fast-forward"。 这种情况通常是因为你当前分支的最新提交落后于远程分支的提交,需要先合并远程分支的更改(例如使用git pull命令),然后再次尝试推送。如果想要了解更多关于fast-forward的详细信息,可以参考git push的帮助文档中的相关说明。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [【git push报错】:See the ‘Note about fast-forwards‘ in ‘git push --help‘ for details](https://blog.csdn.net/scorpio_j/article/details/114756383)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* *3* [git 无法push远程仓库 Note about fast-forwards 问题解决](https://blog.csdn.net/weixin_42596434/article/details/88759295)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值