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

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

git push --force origin master:master

git push origin master:master -f

git push origin master:master --force

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

解决方法2: pull --rebase

git pull origin --rebase

git pull = git fetch + git merge

git pull --rebase = git fetch + git rebase

你可能感兴趣的:(学习笔记,解决问题,过程记录,git,svn,版本控制,代码托管,git)