I have two repos: Market and Android. When I merge Android to Market use these steps:
cd market
git remote add android ../android
git fetch android
git merge --allow-unrelated-histories android/master
But I get this error:
ei@localhost:~/market$ git merge --allow-unrelated-histories android/master error: unknown option `allow-unrelated-histories'
My enviroment: Ubuntu LTS 14.04
ei@localhost:~/market$ git --version
git version 1.9.1
Is this option removed from Git merge, or do I need some extra config?
Any help would be appreciated, thanks!
The –allow-unrelated-histories option will tell the Git that we allow merging branches with no common history base, which then should finish the merge without errors. We should note that for the Git version 2.9 or older, this option is not necessary, and our merge should work without it.
One way to solve the issue is to use the --allow-unrelated-histories git flag. Here the git command will look something like this: git pull origin master --allow-unrelated-histories . You can substitute origin with the remote repository you are pulling from.
The “fatal: refusing to merge unrelated histories” Git error occurs when two unrelated projects are merged (i.e., projects that are not aware of each other's existence and have mismatching commit histories).
In fact, all you need to do to merge unrelated branches is to use the flag --allow-unrelated-histories . This tells Git to combine all the files and commits of both unrelated branches into one branch, as long as there are no file conflicts.
I documented before how that option has been introduced in Git 2.9, June 2016 (as mentioned by merlin2011 in the comments)
Since Ubuntu LTS 14.04 comes with an old 1.9+ Git, you need to reference an up-to-date ppa:
sudo add-apt-repository ppa:git-core/ppa
sudo apt-get update
sudo apt install git
That ppa (Personnal Archive Package) is the git-core/+archive/ubuntu/ppa
, and will include the latest Git 2.11 release.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With