Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

unknown option `allow-unrelated-histories'

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!

like image 796
LF00 Avatar asked Dec 28 '16 06:12

LF00


People also ask

What does allow unrelated histories do?

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.

How do I fix unrelated Git histories?

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.

What does fatal refusing to merge unrelated histories mean?

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).

How do I merge unrelated branches?

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.


1 Answers

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.

like image 197
VonC Avatar answered Oct 10 '22 15:10

VonC