Git提示fatal: refusing to merge unrelated histories


字数:154 阅读时长:1分钟 阅读:85

使用 git remote add origin git@gitlab.test.com/fe-test.git 关联远程仓库,然后使用执行 git push -u origin master 报错:fatal: refusing to merge unrelated historiesUpdates were rejected because the tip of your current branch is behind its remote counterpart

Git

一、完整报错

  1. git pull origin master ,报错:fatal: refusing to merge unrelated histories
  2. git push -u origin master,报错:Updates were rejected because the tip of your current branch is behind its remote counterpart

二、解决办法

git pull 的时候加上 –allow-unrelated-histories 参数,作用就是把两个不相干的分支进行强行合并。

1
2
3
4
5
# 合并
git pull origin master --allow-unrelated-histories

# 再次push
git push -u origin master

欢迎访问:天问博客

本文作者: Tiven
发布时间: 2023-08-25
最后更新: 2023-08-28
本文标题: Git提示fatal: refusing to merge unrelated histories
本文链接: https://www.tiven.cn/p/b3fa3e34/
版权声明: 本作品采用 CC BY-NC-SA 4.0 许可协议进行许可。转载请注明出处!
欢迎留言,提问 ^_^
个人邮箱: tw.email@qq.com
notification icon
博客有更新,将会发送通知给您!