1.拉取镜像时报错
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. If you want to integrate the remote changes,
hint: use 'git pull' before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
出现原因
1.别人先 push 了 团队协作时,别人往远端推送了新提交,而你本地的分支还停留在旧的版本。
2.本地仓库没及时同步远端 你可能有一段时间没 git pull,导致历史落后。
解决方法
不使用git pull origin main而是改为使用git pull --rebase origin main来保持直线历史。
万金油自检顺序
git status # 看看是否有未提交/冲突/进行中操作
git branch -vv # 确认当前分支及其 upstream
git fetch origin # 先拉最新引用
git pull --rebase origin <your-branch> # 整合远端
# 若有冲突:按提示解决 -> git add -> git rebase --continue
git push
或 git pull origin main –allow-unrelated-histories

![[Git]常见错误和解决方法](/images/banner7.webp)

说些什么吧!