当前位置:   article > 正文

git push报 Updates were rejected because the tip of your current branch is behindit 240204

updates were rejected because the tip of your current branch is behind

git push报 Updates were rejected because the tip of your current branch is behindit 240204

当你在使用Git进行推送(push)操作时,如果你的当前分支的最新提交(tip)落后于远程分支的最新提交,就会出现"Updates were rejected because the tip of your current branch is behind its remote counterpart"的错误提示。

Updates were rejected because the tip of your current branch is behindit
翻译为:更新被拒绝,因为当前分支的提示位于其后面

"Updates were rejected because the tip of your current branch is behind"这句话的意思是你的当前分支的最新提交落后于远程分支的最新提交。这通常发生在你试图将本地分支的更改推送到远程分支时。在本地仓库上的修改没有基于远程库最新版本,你的本地仓库版本落后于远程仓库。为了解决这个问题,你需要先将远程分支的更改合并到本地分支,然后再次尝试推送你的更改。

解决方法1: 强制推送 push --force

git push -f origin master:master
  • 1

git push --force origin master:master
  • 1

git push origin master:master -f
  • 1

git push origin master:master --force
  • 1

push -f 的意思是 强制更新
push --force的缩写,
该命令的作用是将自己本地仓库的代码直接推送至仓库,完全以该命令提交为准,之前提交都会被覆盖。

解决方法2: pull --rebase

git pull origin --rebase
  • 1

git pull = git fetch + git merge

git pull --rebase = git fetch + git rebase

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/317359
推荐阅读
  

闽ICP备14008679号