{"thread":{"id":"5837","subject":"Commit to more than one branch at once?","startedAt":"2006-10-06T18:18:42Z","lastAt":"2006-10-06T19:23:59Z","messageCount":5,"participants":["Stefan Richter","Linus Torvalds","Sean","Petr Baudis"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"28308","messageId":"45269E02.50407@s5r6.in-berlin.de","threadId":"5837","inReplyTo":null,"subject":"Commit to more than one branch at once?","fromName":"Stefan Richter","fromEmail":"stefanr@s5r6.in-berlin.de","sentAt":"2006-10-06T18:18:42Z","receivedAt":"2006-10-06T18:18:42Z","isPatch":false,"sender":{"key":"stefanr@s5r6.in-berlin.de","avatar":null},"body":"Hi all,\n\nif I git-cherry-pick a commit from branch A into branch B, this is shown\nas a difference in \"git-log B..A\".\n\nIs it possible to commit a change to two or more branches but preserve\nthe identity of the change? IOW, is there an alternative to\ngit-cherry-pick that does not have above mentioned side effect?\n-- \nStefan Richter\n-=====-=-==- =-=- --==-\nhttp://arcgraph.de/sr/\n"},{"id":"28314","messageId":"Pine.LNX.4.64.0610061136250.3952@g5.osdl.org","threadId":"5837","inReplyTo":"45269E02.50407@s5r6.in-berlin.de","subject":"Re: Commit to more than one branch at once?","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2006-10-06T18:37:36Z","receivedAt":"2006-10-06T18:37:36Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Fri, 6 Oct 2006, Stefan Richter wrote:\n> \n> if I git-cherry-pick a commit from branch A into branch B, this is shown\n> as a difference in \"git-log B..A\".\n> \n> Is it possible to commit a change to two or more branches but preserve\n> the identity of the change? IOW, is there an alternative to\n> git-cherry-pick that does not have above mentioned side effect?\n\nIf you _merge_ the change into both branches, it will be the identical \ncommit in both.\n\nSo for example, one thing people can do is to have a separate \"fixes\" \nbranch that is used for generic bugfixes and, which is merged into all \nother relevant branches.\n\n\t\tLinus\n"},{"id":"28315","messageId":"BAYC1-PASMTP020F3D66B3E46CDBE82D40AE130@CEZ.ICE","threadId":"5837","inReplyTo":"45269E02.50407@s5r6.in-berlin.de","subject":"Re: Commit to more than one branch at once?","fromName":"Sean","fromEmail":"seanlkml@sympatico.ca","sentAt":"2006-10-06T18:38:04Z","receivedAt":"2006-10-06T18:38:04Z","isPatch":false,"sender":{"key":"seanlkml@sympatico.ca","avatar":"https://gravatar.com/avatar/f92923f54fc08c401fc59b71829d4b89e9b8087fbba45ff87c82e6a83aee02ae?d=mp&s=160"},"body":"On Fri, 06 Oct 2006 20:18:42 +0200\nStefan Richter <stefanr@s5r6.in-berlin.de> wrote:\n\n> if I git-cherry-pick a commit from branch A into branch B, this is shown\n> as a difference in \"git-log B..A\".\n> \n> Is it possible to commit a change to two or more branches but preserve\n> the identity of the change? IOW, is there an alternative to\n> git-cherry-pick that does not have above mentioned side effect?\n\nShort answer:\n\nNo.\n\nSlightly longer answer:\n\nOnly merging the branches will make the commit show up in branch B with\nthe same SHA1 number (or identity) that it had in branch A.  This is a\nfundamental part of Git.  The sha1 of each commit is based in part on\nthe sha1 of its parent.  Thus it's impossible[1] to copy a commit to\nanother branch (ie. reparent it) without changing its identity.\n\nSean\n\n[1]  Okay, more or less impossible.. don't ask me do the math.\n"},{"id":"28317","messageId":"20061006185227.GV20017@pasky.or.cz","threadId":"5837","inReplyTo":"45269E02.50407@s5r6.in-berlin.de","subject":"Re: Commit to more than one branch at once?","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2006-10-06T18:52:27Z","receivedAt":"2006-10-06T18:52:27Z","isPatch":false,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Dear diary, on Fri, Oct 06, 2006 at 08:18:42PM CEST, I got a letter\nwhere Stefan Richter <stefanr@s5r6.in-berlin.de> said that...\n> if I git-cherry-pick a commit from branch A into branch B, this is shown\n> as a difference in \"git-log B..A\".\n> \n> Is it possible to commit a change to two or more branches but preserve\n> the identity of the change? IOW, is there an alternative to\n> git-cherry-pick that does not have above mentioned side effect?\n\n  Philosophical answer:\n\n  This is a point where it shows that Git is snapshot-based, not\nchangeset-based version control system. So you are not committing a\nchange, you are committing a snapshot taken after the change. So only\nsnapshots have identity and if the snapshots differ, they obviously have\ndifferent identity. Thus your commit has to have different identity.\nFurthermore the commit ties the snapshot with some history (and only\nthis is the first moment where the concept of the 'change' emerges), and\nif you have different history, identity of your commit cannot be\nthe same either.\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nStuff: http://pasky.or.cz/\n#!/bin/perl -sp0777i<X+d*lMLa^*lN%0]dsXx++lMlN/dsM0<j]dsj\n$/=unpack('H*',$_);$_=`echo 16dio\\U$k\"SK$/SM$n\\EsN0p[lN*1\nlK[d2%Sa2/d0$^Ixp\"|dc`;s/\\W//g;$_=pack('H*',/((..)*)$/)\n"},{"id":"28323","messageId":"4526AD4F.70305@s5r6.in-berlin.de","threadId":"5837","inReplyTo":"BAYC1-PASMTP020F3D66B3E46CDBE82D40AE130@CEZ.ICE","subject":"Re: Commit to more than one branch at once?","fromName":"Stefan Richter","fromEmail":"stefanr@s5r6.in-berlin.de","sentAt":"2006-10-06T19:23:59Z","receivedAt":"2006-10-06T19:23:59Z","isPatch":false,"sender":{"key":"stefanr@s5r6.in-berlin.de","avatar":null},"body":"Sean wrote:\n> Only merging the branches will make the commit show up in branch B with\n> the same SHA1 number (or identity) that it had in branch A.  This is a\n> fundamental part of Git.  The sha1 of each commit is based in part on\n> the sha1 of its parent.  Thus it's impossible[1] to copy a commit to\n> another branch (ie. reparent it) without changing its identity.\n> \n> Sean\n> \n> [1]  Okay, more or less impossible.. don't ask me do the math.\n\nAh, I didn't see the wood for the trees. And this dependence of a\ncommit's identity on the history is also a (or the) reason why mergers\nare necessarily spliced in as commits with unique identity too...\n-- \nStefan Richter\n-=====-=-==- =-=- --==-\nhttp://arcgraph.de/sr/\n"}]}