Tiven

Tiven

博观而约取,厚积而薄发

天问的个人网站(天问博客),专注于Node.js、Vue.js、React、Vite、Npm、Nginx等大前端技术。不断学习新技术,记录日常开发问题,持续分享coding,极客开源,共同进步。生命不息,奋斗不止... [ hexo blog ]

Git提示fatal: refusing to merge unrelated histories


使用 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 参数,作用就是把两个不相干的分支进行强行合并。

# 合并
git pull origin master --allow-unrelated-histories

# 再次push
git push -u origin master

欢迎访问:天问博客