{"thread":{"id":"1720","subject":"Replay on arbitrary branches","startedAt":"2005-09-03T01:11:40Z","lastAt":"2005-09-03T02:17:30Z","messageCount":3,"participants":["Martin Langhoff","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"8025","messageId":"46a038f905090218113587f64f@mail.gmail.com","threadId":"1720","inReplyTo":null,"subject":"Replay on arbitrary branches","fromName":"Martin Langhoff","fromEmail":"martin.langhoff@gmail.com","sentAt":"2005-09-03T01:11:40Z","receivedAt":"2005-09-03T01:11:40Z","isPatch":false,"sender":{"key":"martin.langhoff@gmail.com","avatar":"https://gravatar.com/avatar/1e3f311b6c4c15836501901ca58f8c0b0667246488084ba524d8bc9867e22fd9?d=mp&s=160"},"body":"Is there a way to replay a merge on a head that GIT considers unrelated? \n\nI have been playing with exporting to mbox format with\ngit-format-patch-script, and applying those to the destination branch.\nHowever, this drops binary files -- and I _do_ have binary files in\nsome of the projects I work on.\n\ncheers,\n\n\nmartin\n"},{"id":"8027","messageId":"7vwtlydisj.fsf@assigned-by-dhcp.cox.net","threadId":"1720","inReplyTo":"46a038f905090218113587f64f@mail.gmail.com","subject":"Re: Replay on arbitrary branches","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-09-03T01:47:08Z","receivedAt":"2005-09-03T01:47:08Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Martin Langhoff <martin.langhoff@gmail.com> writes:\n\n> Is there a way to replay a merge on a head that GIT considers unrelated? \n>\n> I have been playing with exporting to mbox format with\n> git-format-patch-script, and applying those to the destination branch.\n> However, this drops binary files -- and I _do_ have binary files in\n> some of the projects I work on.\n\nI do not think your question has much to do with 'GIT considers\nunrelated'.  The 'git resolve' machinery would have the same\nproblem with related trees, if you do keep track of binary\nfiles, and you are changing them in both branches.  The 3-way\nmerge resolution step will eventually invoke 'merge' or 'diff3'\nand you lose.\n\nAbout 'unrelated' trees, if you know of a good tree you can use\nas a reference point, you could manually emulate what 'git\nresolve' does.  Let's say you have project A and project B; for\nwhatever historical reasons you do not have a common ancestor of\nthese project master branch heads.\n\n    $ git clone projectA/.git merged\n    $ cd merged\n    $ git fetch ../projectB/.git master:b\n\nNow refs/heads/master is projectA's head, and refs/heads/b is\nprojectB's.  They may not be related, but if you know a commit c\nthat was in some shared past from both projects, you probably\ncan:\n\n    $ git-read-tree -m -u c master b\n    $ git-merge-cache -o git-merge-one-file-script -a\n\nIf the resulting tree looks reasonable, you could now commit it\ntelling 'git-commit-tree' that the parents of the new commit are\nmaster and b, and you practically merged two projects.\n"},{"id":"8028","messageId":"46a038f90509021917e0833a2@mail.gmail.com","threadId":"1720","inReplyTo":"7vwtlydisj.fsf@assigned-by-dhcp.cox.net","subject":"Re: Replay on arbitrary branches","fromName":"Martin Langhoff","fromEmail":"martin.langhoff@gmail.com","sentAt":"2005-09-03T02:17:30Z","receivedAt":"2005-09-03T02:17:30Z","isPatch":false,"sender":{"key":"martin.langhoff@gmail.com","avatar":"https://gravatar.com/avatar/1e3f311b6c4c15836501901ca58f8c0b0667246488084ba524d8bc9867e22fd9?d=mp&s=160"},"body":"Agreed on the impossibility of 3-way merges with binary files. In the\nbranch I want to replay, though, I have commits that add and change\nbinary files.\n\n> About 'unrelated' trees, if you know of a good tree you can use\n\n<setup snipped>\n\n>     $ git-read-tree -m -u c master b\n>     $ git-merge-cache -o git-merge-one-file-script -a\n> \n> If the resulting tree looks reasonable, you could now commit it\n> telling 'git-commit-tree' that the parents of the new commit are\n> master and b, and you practically merged two projects.\n\nCool! I think this is what I was looking for. The call to\ngit-read-tree will act as if A and B had branched off at tree \"C\".\nI'll have to read the doco on git-read-tree and git-merge-cache a bit\nmore to feel comfortable with this voodoo, but it's great.\n\ncheers,\n\n\nmartin\n"}]}