使用 git remote add origin git@gitlab.test.com/fe-test.git
关联远程仓库,然后使用执行 git push -u origin master
报错:fatal: refusing to merge unrelated histories
,Updates were rejected because the tip of your current branch is behind its remote counterpart
。
一、完整报错
git pull origin master
,报错:fatal: refusing to merge unrelated histories
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
欢迎访问:天问博客