merging in unrelated git branches

Sometimes when you develop code outside the "official" repository for some project, it turns out that after a few months of hacking, your code is actually suitable for inclusion in the mainline.

Typically when this is the case, the code is just imported directly, throwing away the historical records of how that code came to be.

This is a travesty. Not only is the future deprived of the past, you as a hacker do not get sufficient recognition of your efforts. (What good are perfect patches if you do not reap their accolades?)

But suffer not: while Git does not support direct merges between unrelated branches, it can be made to comply. Script here: git-merge-unrelated-branch. (Example commit.)

Be not deprived of your just deserts!

5 responses

  1. Maciej Piechotka says:

    It seems to support:
    60ce752c in git://github.com/uzytkownik/gnome-overlay.git
    How the branches may be more unrelated (or I misunderstood something).

  2. Elijah Newren says:

    I thought 'eg pull REPO BRANCH' did this just fine; I've used it a time or two to merge branches with no common history. Are there problems in less simplistic cases that need your script?

  3. Elijah Newren says:

    Um, er, I mean 'git pull REPO BRANCH'. Same thing, though.

  4. Andy Wingo says:

    Well ain't I the fool! Elijah it does appear to work; although I normally use fetch + merge, that seemed to work as well.

    I swear that a few months ago when I first tried this, it did not do the right thing, erroring out when I went to merge. I tried all merge strategies, even. May my crufty script rot in obscurity, then.

  5. Sam Vilain says:

    It can support those well actually, just set up a graft and you can fake the history being joined in the past. See Documentation/repository-layout.txt in the git distribution. You can later make it permanent with git-filter-branch.

Comments are closed.