{"thread":{"id":"24925","subject":"merging branches with separate but identical history","startedAt":"2010-08-31T21:01:09Z","lastAt":"2010-09-01T12:35:41Z","messageCount":3,"participants":["Craig de Stigter","Jonathan Nieder","Henrik Grubbström"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"149495","messageId":"AANLkTikTzZe=c=RaEYSr_wjfHht4PZihggnV9vEOehvy@mail.gmail.com","threadId":"24925","inReplyTo":"AANLkTikoDkhKTRmob=B_NYJSYoby0J3Zo-Qp43AU9WfZ@mail.gmail.com","subject":"merging branches with separate but identical history","fromName":"Craig de Stigter","fromEmail":"craig.destigter@koordinates.com","sentAt":"2010-08-31T21:01:09Z","receivedAt":"2010-08-31T21:01:09Z","isPatch":false,"sender":{"key":"craig.destigter@koordinates.com","avatar":"https://gravatar.com/avatar/5f34ac1c172de83e085896805c18eb8ea55b7194fe992d17c3e0eccce1efffee?d=mp&s=160"},"body":"Hi list\n\nI have two branches which start with the same commits, and I want to merge them.\nI believe the two branches were individually pulled from the same SVN\nrepo, so they look like this:\n\nbranch1: a--b--c--d--e--f--1--3--5\nbranch2: a--b--c--d--e--f--2--4--6\n\nIf I do:\n> git checkout branch1\n> git merge branch2\nMerge made by recursive\n\nThe merge succeeds but the commits in each branch aren't squashed\ntogether (git log shows two commits for each actual commit)\n i.e., now my history looks like this:\n\na--a--b--b--c--c--d--d--e--e--f--f--1--2--3--4--5--6\n\nIs there a way to do this without the duplicates? (perhaps a way to\nmark the branch as merged up to 'f', without actually performing a\nmerge?)\n\nThanks\nCraig de Stigter\n--\nKoordinates Ltd\nPO Box 1604, Shortland St, Auckland, New Zealand\nPhone +64-9-966 0433 Fax +64-9-969 0045\nWeb http://www.koordinates.com\n"},{"id":"149499","messageId":"20100831211602.GF5911@burratino","threadId":"24925","inReplyTo":"AANLkTikTzZe=c=RaEYSr_wjfHht4PZihggnV9vEOehvy@mail.gmail.com","subject":"Re: merging branches with separate but identical history","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-08-31T21:16:02Z","receivedAt":"2010-08-31T21:16:02Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Hi,\n\nCraig de Stigter wrote:\n\n> I have two branches which start with the same commits, and I want to merge them.\n> I believe the two branches were individually pulled from the same SVN\n> repo\n[...]\n> If I do:\n>> git checkout branch1\n>> git merge branch2\n> Merge made by recursive\n> \n> The merge succeeds but the commits in each branch aren't squashed\n> together (git log shows two commits for each actual commit)\n>  i.e., now my history looks like this:\n> \n> a--a--b--b--c--c--d--d--e--e--f--f--1--2--3--4--5--6\n> \n> Is there a way to do this without the duplicates? (perhaps a way to\n> mark the branch as merged up to 'f', without actually performing a\n> merge?)\n\nNo.  I would suggest trying\n\n git cat-file commit a\n git cat-file commit A\n\nwhere a and A are the two versions of \"a\" and comparing them.\nHow do they differ?\n\nIf you don't care about superseding the old history and just want\nto combine the two branches into a single history, you can try something\nlike this:\n\n $ git checkout branch1\n $ git rebase -i branch1~3 --onto branch2~3\n $ git merge branch2\n\nIf the history after the fork point is not linear, you can still do\nsomething very similar with grafts.  See git-filter-branch(1) for\ndetails.\n\nHope that helps,\nJonathan\n"},{"id":"149555","messageId":"loom.20100901T142437-744@post.gmane.org","threadId":"24925","inReplyTo":"AANLkTikTzZe=c=RaEYSr_wjfHht4PZihggnV9vEOehvy@mail.gmail.com","subject":"Re: merging branches with separate but identical history","fromName":"Henrik Grubbström","fromEmail":"grubba@grubba.org","sentAt":"2010-09-01T12:35:41Z","receivedAt":"2010-09-01T12:35:41Z","isPatch":false,"sender":{"key":"grubba@grubba.org","avatar":"https://avatars.githubusercontent.com/u/1169458?v=4"},"body":"Craig de Stigter <craig.destigter <at> koordinates.com> writes:\n\n> Hi list\n\nHi.\n\n> I have two branches which start with the same commits, and I want to merge\n> them.\n> I believe the two branches were individually pulled from the same SVN\n> repo, so they look like this:\n> \n> branch1: a--b--c--d--e--f--1--3--5\n> branch2: a--b--c--d--e--f--2--4--6\n[...]\n> Is there a way to do this without the duplicates? (perhaps a way to\n> mark the branch as merged up to 'f', without actually performing a\n> merge?)\n\nYes, you can use grafts (cf gitrepository-layout(5)) to rewrite the parent\npointer for eg commit 2 from f(2) to f(1).\n\n> Thanks\n> Craig de Stigter\n\n-- \nHenrik Grubbström                                         <grubba@grubba.org>\nRoxen Internet Software AB                                <grubba@roxen.com>\n"}]}