! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/agoni-soul/RetrofitTest_v2.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
网上百度一种解决方案是:
git pull origin master
git push origin master
但是这种解决方案仍然报错:
>git pull origin master
From https://github.com/agoni-soul/RetrofitTest_v2
* branch master -> FETCH_HEAD
fatal: refusing to merge unrelated histories再次百度查找“fatal: refusing to merge unrelated histories ”
如下原因:
git pull 失败 ,提示:fatal: refusing to merge unrelated histories
其实这个问题是因为 两个 根本不相干的 git 库, 一个是本地库, 一个是远端库, 然后本地要去推送到远端, 远端觉得这个本地库跟自己不相干, 所以告知无法合并
因而结合文章提及的解决方案:
git pull origin master --allow-unrelated-histories后面加上 --allow-unrelated-histories , 把两段不相干的 分支进行强行合并
后面再push就可以了 git push origin master
即可提交成功。
git 出现 fatal: refusing to merge unrelated histories 错误