Trying to pull files from my Github repository: “refusing to merge unrelated histories”

前端 未结 8 507
傲寒
傲寒 2020-12-04 05:34

I\'m learning git, and I\'m following the Git community book.

Previously (long time ago) I made a public repository on Github, with some files. Now I set up a local

8条回答
  •  再見小時候
    2020-12-04 06:18

    When I used --allow-unrelated-histories, this command generated too many conflicts. There were conflicts in files which I didn't even work on. To get over the error " Refusing to merge unrelated histories", I used following rebase command:

    git pull --rebase=preserve --allow-unrelated-histories
    

    After this commit the uncommitted changes with a commit message. Finally, run the following command:

    git rebase --continue
    

    After this, my working copy was up-to-date with the remote copy and I was able to push my changes as before. No more unrelated histories error while pulling.

提交回复
热议问题