0

I am trying to understand merging of unrelated histories. Git 'merge' command has an option "--allow-unmatched histories" to merge unrelated histories. I am missing some clarity here. The root folder in GIT is called as 'project'. project contains many repositories. Each repo may have several branches.

Considering all this. I have two 'projects' (a, b). In project 'a', I have a repo called 'arepo'. 'arepo' have a branch 'abranch'. Similarly, there is project 'b'. project 'b' has a repo called 'brepo'. 'brepo' has a branch called 'bbranch'.

The following picture depicts the situation:- Unrelated branches

In this situation can we merge "abranch" and "bbranch" using "allow-unrelated-histories" option of GIT Merge?

Thanks in advance.

Nditah
  • 1,429
  • 19
  • 23
  • Maybe [this](https://stackoverflow.com/questions/37937984/git-refusing-to-merge-unrelated-histories) or [this](https://stackoverflow.com/questions/45272492/git-refusing-to-merge-unrelated-histories-what-is-unrelated-histories) will help – Soenhay Oct 05 '17 at 21:21

1 Answers1

0

From here it says:

--allow-unrelated-histories By default, git merge command refuses to merge histories that do not share a common ancestor. This option can be used to override this safety when merging histories of two projects that started their lives independently. As that is a very rare occasion, no configuration variable to enable this by default exists and will not be added.

So it would appear that it is possible to merge unrelated histories by using the --allow-unrelated-histories option.

Soenhay
  • 3,958
  • 5
  • 34
  • 60
  • Thank you so much for your response. I do understand about possibilities. my ambiguity is about "unrelated histories". Is the diagram that I presented is accurate example for unrelated histories or not? I am trying to understand what are called "unrelated histories"? – Muralidhar Yaragalla Oct 06 '17 at 03:05
  • Unrelated histories just means that the branches do not have a common ancestor just like in your diagram. So I would say that your diagram is accurate. If project a and b were different repositories then as far as git is concerned they do not have a common ancestor even though b might just be b copy of a. – Soenhay Oct 06 '17 at 04:13
  • [Here](https://stackoverflow.com/questions/1425892/how-do-you-merge-two-git-repositories) is another link that might help. – Soenhay Oct 06 '17 at 04:19
  • For contrast, an example of related histories would be two branches in the same project that originated from the same root commit at some point in time. Since they would share alot of similarities they would be able to merge by default. – Soenhay Oct 06 '17 at 04:29