{"thread":{"id":"29028","subject":"two branches: keep one difference but merge others forth and back","startedAt":"2011-11-27T17:31:42Z","lastAt":"2011-11-30T12:37:13Z","messageCount":3,"participants":["Gelonida N","Carlos Martín Nieto","Tor Arntsen"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"180022","messageId":"jats5v$r7c$1@dough.gmane.org","threadId":"29028","inReplyTo":null,"subject":"two branches: keep one difference but merge others forth and back","fromName":"Gelonida N","fromEmail":"gelonida@gmail.com","sentAt":"2011-11-27T17:31:42Z","receivedAt":"2011-11-27T17:31:42Z","isPatch":false,"sender":{"key":"gelonida@gmail.com","avatar":null},"body":"Hi,\n\n\nIs this possible.\n\n\nI'd like to have two branches.\n\nIf possible I would be able to merge forth and back between both of them.\n\nHowever I would like, that certain differences will be kept between both\nbranches.\n\nIs there any way to tell git to permanently ignoring certain commits\nfrom merging?\n\n\nExample:\n---------\n   Normally shell scripts would have a first line of\n'#!/bin/bash',\nbut in a certain branch I would like that the first lines would be\n\n'#!/usr/local/bin/bash'\n\nAll from then on however I'd like to be able to commit on both branches\nand to merge from the other branches (and always keep this difference)\n\nWhat I tried:\n-------------\nMy first naive approach was:\n- create shell scripts in master,\n- create then a branch named 'my_shell'\n- modify first lines of shell scripts in this branch and commit\n- checkout master\n- merge my_shell to master with merge strategy 'ours'\n  git pull my_shell -s ours\n- now I changed something else in master\n- when I try to merge back to branch my_shell I will not only get\n  the most recent changes done in master, but I will also undo the\nchanges in line 1 of my shell scripts.\n\nSo it seems I am not doing things as one should.\n\n\nPotential other strategies:\n----------------------------\n- never commit anything on branch my_shell and just pull regularly\n  from master to keep it synced.\n\n- commit changes / bug fixes also on branch my_shell, but NEVER merge\nback to master. If a change grom my_shell is really needed on master,\nthen just cherry-pick.\n\n\nThanks in advance for suggestions how you would deal with such 'situations'\n"},{"id":"180048","messageId":"20111128152536.GB2386@beez.lab.cmartin.tk","threadId":"29028","inReplyTo":"jats5v$r7c$1@dough.gmane.org","subject":"Re: two branches: keep one difference but merge others forth and back","fromName":"Carlos Martín Nieto","fromEmail":"cmn@elego.de","sentAt":"2011-11-28T15:25:36Z","receivedAt":"2011-11-28T15:25:36Z","isPatch":false,"sender":{"key":"cmn@elego.de","avatar":"https://avatars.githubusercontent.com/u/335443?v=4"},"body":"On Sun, Nov 27, 2011 at 06:31:42PM +0100, Gelonida N wrote:\n> Hi,\n> \n> \n> Is this possible.\n> \n> \n> I'd like to have two branches.\n> \n> If possible I would be able to merge forth and back between both of them.\n> \n> However I would like, that certain differences will be kept between both\n> branches.\n> \n> Is there any way to tell git to permanently ignoring certain commits\n> from merging?\n\nThis goes against what a merge is.\n\n> \n> \n> Example:\n> ---------\n>    Normally shell scripts would have a first line of\n> '#!/bin/bash',\n> but in a certain branch I would like that the first lines would be\n> \n> '#!/usr/local/bin/bash'\n> \n> All from then on however I'd like to be able to commit on both branches\n> and to merge from the other branches (and always keep this difference)\n> \n> What I tried:\n> -------------\n> My first naive approach was:\n> - create shell scripts in master,\n> - create then a branch named 'my_shell'\n> - modify first lines of shell scripts in this branch and commit\n> - checkout master\n> - merge my_shell to master with merge strategy 'ours'\n>   git pull my_shell -s ours\n> - now I changed something else in master\n> - when I try to merge back to branch my_shell I will not only get\n>   the most recent changes done in master, but I will also undo the\n> changes in line 1 of my shell scripts.\n> \n> So it seems I am not doing things as one should.\n\nIf you tell git to merge, it expects that you want to take the changes\ndone in the other branch.\n\n> \n> \n> Potential other strategies:\n> ----------------------------\n> - never commit anything on branch my_shell and just pull regularly\n>   from master to keep it synced.\n> \n> - commit changes / bug fixes also on branch my_shell, but NEVER merge\n> back to master. If a change grom my_shell is really needed on master,\n> then just cherry-pick.\n> \n> \n> Thanks in advance for suggestions how you would deal with such 'situations'\n\nYou can amend the merge (or the next merge) commit so you undo that\nchange. Git should leave that line alone as long as you don't change\nit.\n\nOr you could have a branch where you make changes and two branches\nwhere you change the hashbang. Merging from the main branch into the\nspecific branches won't touch the hashbang, as long as you don't touch\nit.\n\n   cmn\n"},{"id":"180152","messageId":"CABNEGjwJTBEvTcYPS1+DfJGuASGnaQq3wM=zYshvYXdhmnUEUg@mail.gmail.com","threadId":"29028","inReplyTo":"jats5v$r7c$1@dough.gmane.org","subject":"Re: two branches: keep one difference but merge others forth and back","fromName":"Tor Arntsen","fromEmail":"tor@spacetec.no","sentAt":"2011-11-30T12:37:13Z","receivedAt":"2011-11-30T12:37:13Z","isPatch":false,"sender":{"key":"tor@spacetec.no","avatar":null},"body":"On Sun, Nov 27, 2011 at 18:31, Gelonida N <gelonida@gmail.com> wrote:\n> Hi,\n>\n>\n> Is this possible.\n>\n>\n> I'd like to have two branches.\n>\n> If possible I would be able to merge forth and back between both of them.\n>\n> However I would like, that certain differences will be kept between both\n> branches.\n>\n> Is there any way to tell git to permanently ignoring certain commits\n> from merging?\n\nInstead of merging, you could use rebasing. So you have one\ndevelopment branch where you do all the changes, and then another\nbranch where the only commit there is that special difference (as in\nyour /usr/bin/bash example). From then on you only develop/maintain\nthe original branch, and then you rebase the 'special' branch on top\nof the development branch. Then you get all the updates, plus your\nspecial change applied on top each time.\nLikewise, if you have two variants (say, one /bin/bash, another\n/usr/bin/bash, and then one with /usr/local/bin/bash) then create two\nbranches and rebase them on top of the third branch (the development\nbranch) every time you wish to deploy new updates.\n\n-Tor\n"}]}