我有同样的问题。问题很遥远,有些东西阻止了这种情况。
我首先创建了一个本地存储库。我在本地添加了一个LICENSE
and README.md
文件并提交。
然后我想要一个远程存储库,所以我在GitHub上创建了一个。在这里,我检查“使用README初始化此存储库”时犯了一个错误,该错误也在远程创建了README.md。
所以现在当我跑步
git push --set-upstream origin master
我有:
error: failed to push some refs to 'https://github.com/lokeshub/myTODs.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes
(e.g. hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
现在克服这个我做了
git pull origin master
导致以下错误:
From https://github.com/lokeshub/myTODs
branch master -> FETCH_HEAD
fatal: refusing to merge unrelated histories**
我试过了:
git pull origin master --allow-unrelated-histories
结果:
From https://github.com/lokeshub/myTODs
* branch master -> FETCH_HEAD
Auto-merging README.md
CONFLICT (add/add): Merge conflict in README.md
Automatic merge failed;
fix conflicts and then commit the result.
解:
我删除了远程存储库并创建了一个新文件(我认为只有删除文件才README
可以使用),然后下面的方法起作用了:
git remote rm origin
git remote add origin https://github.com/lokeshub/myTODOs.git
git push --set-upstream origin master
git-rebase
情况,而答案则给以下情况提供标志git-merge