Git refusing to merge unrelated histories on rebase

后端 未结 23 2325
旧巷少年郎
旧巷少年郎 2020-11-22 08:30

During git rebase origin/development the following error message is shown from Git:

fatal: refusing to merge unrelated histories
Error redoing m         


        
相关标签:
23条回答
  • 2020-11-22 09:02

    For Googlers:

    If you created a new repo on GitHub and accidentally initialized it with README or .gitignore files.

    If you found yourself unable to merge or rebase because .git folder got corrupted.

    Then:

    • Create a new folder
    • git clone
    • Paste all your files into this folder

    Now the local and remote will have "related histories" and will merge or rebase happily.

    0 讨论(0)
  • 2020-11-22 09:03

    In my case, the error was just fatal: refusing to merge unrelated histories on every try, especially the first pull request after remotely adding a Git repository.

    Using the --allow-unrelated-histories flag worked with a pull request in this way:

    git pull origin branchname --allow-unrelated-histories
    
    0 讨论(0)
  • 2020-11-22 09:04

    Try the following command:

    git pull origin master --allow-unrelated-histories
    

    This should solve your problem.

    0 讨论(0)
  • 2020-11-22 09:04

    For Android Studio and IntelliJ:

    First, commit everything and resolve any conflicts.

    Then open the terminal from below of IDE and enter:

    git pull origin master --allow-unrelated-histories
    

    Now you can push.

    0 讨论(0)
  • 2020-11-22 09:05

    For this, enter the command:

    git pull origin branchname --allow-unrelated-histories
    

    For example,

    git pull origin master --allow-unrelated-histories
    

    Reference:

    GitHub unrelated histories issue

    0 讨论(0)
提交回复
热议问题