8

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!

LF00
  • 27,015
  • 29
  • 156
  • 295
  • 2
    [This answer](http://stackoverflow.com/a/37938036/391161) seems to indicate that this option was introduced in 2.9 and that your version of git should default to the behavior with this option set. – merlin2011 Dec 28 '16 at 06:53
  • Thank you. I've done apt-get update and apt-get upgrade. I thought after that my version is the latest. From you comment, I've to manuall install the latest version of git. I'll try it now. – LF00 Dec 28 '16 at 06:57
  • 1
    Those two commands will generally only get you to the latest version of `git` that the repository maintainers have updated the repository to, and your version of Ubuntu was released in April 2014. – merlin2011 Dec 28 '16 at 06:59
  • Thanks again. got it. – LF00 Dec 28 '16 at 07:04

1 Answers1

19

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.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks, I'm trying. Its not smoothly. I fails to update it for the Great FireWall. Now I'm setting proxy for apt-get, I used socks5. I have google some solutions to use the socks5, just on the working. – LF00 Dec 28 '16 at 07:50
  • 1
    @KrisRoofe socks might work. If not: http://danrossiter.org/tunneling-through-the-great-firewall-of-china-again/ or http://blog.zorinaq.com/my-experience-with-the-great-firewall-of-china/ – VonC Dec 28 '16 at 08:01
  • @PeterKrauss Good point. I have edited the answer to make that step more visible. – VonC Mar 12 '18 at 21:53
  • I have the same problem, but my app is deployed on Heroku. Do you know how can I run these commands on Heroku? – E A Apr 26 '19 at 14:45
  • @EmadAghayi I don't know. Maybe through the console? (https://devcenter.heroku.com/changelog-items/1137). I you do have a console, what version of Git is install on your Heroku dev platform? – VonC Apr 26 '19 at 14:59
  • I encountered the same problem as the OP (LF00). But if I am using a GIT version that is older than v2.9, shouldn't I be able to merge two local GIT repos without using the --allow-unrelated-histories option? – SQA777 Apr 08 '21 at 23:31
  • @SQA777 "older than 2.9" means a version released *before* 2.9, a version where `--allow-unrelated-histories` indeed did not yet exist. So yes, you should be able to merge without using that option, since a Git "older than" 2.9 does not have that option. A Git more recent than 2.9 (so 2.10 up to the current 2.31.1) would have that option. – VonC Apr 08 '21 at 23:35
  • VonC, yes, that's what I meant - older than v2.9 means I should be allowed to merge two local GIT repos without using "--allow-unrelated histories" option. My GIT version is v1.8.3.1. However, even if I try a git merge w/o the --allow-unrelated-histories option, I get an error message: "fatal: old_repo - not something we can merge". So there's another problem that's orthogonal to the OP's question. However, I wanted to verify that I can do a merge w/o the --allow-unrelated-histories option on older versions of GIT – SQA777 Apr 08 '21 at 23:57
  • @SQA777 That is why `--allow-unrelated histories` has been introduced in 2.9: to allow such a merge. – VonC Apr 08 '21 at 23:58
  • @VonC, just to be clear, are you saying that I cannot do a "git merge" on two local GIT repos unless I use the --allow-unrelated-histories option? – SQA777 Apr 09 '21 at 00:26
  • 1
    @SQA777 If those two repository does not have a common history, then yes, you cannot do a merge; only the option `--allow-unrelated-histories` would allow such a merge. – VonC Apr 09 '21 at 00:29