* two branches: keep one difference but merge others forth and back
@ 2011-11-27 17:31 Gelonida N
2011-11-28 15:25 ` Carlos Martín Nieto
2011-11-30 12:37 ` Tor Arntsen
0 siblings, 2 replies; 3+ messages in thread
From: Gelonida N @ 2011-11-27 17:31 UTC (permalink / raw)
To: git
Hi,
Is this possible.
I'd like to have two branches.
If possible I would be able to merge forth and back between both of them.
However I would like, that certain differences will be kept between both
branches.
Is there any way to tell git to permanently ignoring certain commits
from merging?
Example:
---------
Normally shell scripts would have a first line of
'#!/bin/bash',
but in a certain branch I would like that the first lines would be
'#!/usr/local/bin/bash'
All from then on however I'd like to be able to commit on both branches
and to merge from the other branches (and always keep this difference)
What I tried:
-------------
My first naive approach was:
- create shell scripts in master,
- create then a branch named 'my_shell'
- modify first lines of shell scripts in this branch and commit
- checkout master
- merge my_shell to master with merge strategy 'ours'
git pull my_shell -s ours
- now I changed something else in master
- when I try to merge back to branch my_shell I will not only get
the most recent changes done in master, but I will also undo the
changes in line 1 of my shell scripts.
So it seems I am not doing things as one should.
Potential other strategies:
----------------------------
- never commit anything on branch my_shell and just pull regularly
from master to keep it synced.
- commit changes / bug fixes also on branch my_shell, but NEVER merge
back to master. If a change grom my_shell is really needed on master,
then just cherry-pick.
Thanks in advance for suggestions how you would deal with such 'situations'
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: two branches: keep one difference but merge others forth and back
2011-11-27 17:31 two branches: keep one difference but merge others forth and back Gelonida N
@ 2011-11-28 15:25 ` Carlos Martín Nieto
2011-11-30 12:37 ` Tor Arntsen
1 sibling, 0 replies; 3+ messages in thread
From: Carlos Martín Nieto @ 2011-11-28 15:25 UTC (permalink / raw)
To: Gelonida N; +Cc: git
[-- Attachment #1: Type: text/plain, Size: 2330 bytes --]
On Sun, Nov 27, 2011 at 06:31:42PM +0100, Gelonida N wrote:
> Hi,
>
>
> Is this possible.
>
>
> I'd like to have two branches.
>
> If possible I would be able to merge forth and back between both of them.
>
> However I would like, that certain differences will be kept between both
> branches.
>
> Is there any way to tell git to permanently ignoring certain commits
> from merging?
This goes against what a merge is.
>
>
> Example:
> ---------
> Normally shell scripts would have a first line of
> '#!/bin/bash',
> but in a certain branch I would like that the first lines would be
>
> '#!/usr/local/bin/bash'
>
> All from then on however I'd like to be able to commit on both branches
> and to merge from the other branches (and always keep this difference)
>
> What I tried:
> -------------
> My first naive approach was:
> - create shell scripts in master,
> - create then a branch named 'my_shell'
> - modify first lines of shell scripts in this branch and commit
> - checkout master
> - merge my_shell to master with merge strategy 'ours'
> git pull my_shell -s ours
> - now I changed something else in master
> - when I try to merge back to branch my_shell I will not only get
> the most recent changes done in master, but I will also undo the
> changes in line 1 of my shell scripts.
>
> So it seems I am not doing things as one should.
If you tell git to merge, it expects that you want to take the changes
done in the other branch.
>
>
> Potential other strategies:
> ----------------------------
> - never commit anything on branch my_shell and just pull regularly
> from master to keep it synced.
>
> - commit changes / bug fixes also on branch my_shell, but NEVER merge
> back to master. If a change grom my_shell is really needed on master,
> then just cherry-pick.
>
>
> Thanks in advance for suggestions how you would deal with such 'situations'
You can amend the merge (or the next merge) commit so you undo that
change. Git should leave that line alone as long as you don't change
it.
Or you could have a branch where you make changes and two branches
where you change the hashbang. Merging from the main branch into the
specific branches won't touch the hashbang, as long as you don't touch
it.
cmn
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 490 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: two branches: keep one difference but merge others forth and back
2011-11-27 17:31 two branches: keep one difference but merge others forth and back Gelonida N
2011-11-28 15:25 ` Carlos Martín Nieto
@ 2011-11-30 12:37 ` Tor Arntsen
1 sibling, 0 replies; 3+ messages in thread
From: Tor Arntsen @ 2011-11-30 12:37 UTC (permalink / raw)
To: Gelonida N; +Cc: git
On Sun, Nov 27, 2011 at 18:31, Gelonida N <gelonida@gmail.com> wrote:
> Hi,
>
>
> Is this possible.
>
>
> I'd like to have two branches.
>
> If possible I would be able to merge forth and back between both of them.
>
> However I would like, that certain differences will be kept between both
> branches.
>
> Is there any way to tell git to permanently ignoring certain commits
> from merging?
Instead of merging, you could use rebasing. So you have one
development branch where you do all the changes, and then another
branch where the only commit there is that special difference (as in
your /usr/bin/bash example). From then on you only develop/maintain
the original branch, and then you rebase the 'special' branch on top
of the development branch. Then you get all the updates, plus your
special change applied on top each time.
Likewise, if you have two variants (say, one /bin/bash, another
/usr/bin/bash, and then one with /usr/local/bin/bash) then create two
branches and rebase them on top of the third branch (the development
branch) every time you wish to deploy new updates.
-Tor
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-11-30 12:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-27 17:31 two branches: keep one difference but merge others forth and back Gelonida N
2011-11-28 15:25 ` Carlos Martín Nieto
2011-11-30 12:37 ` Tor Arntsen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).