proper way to merge?

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

proper way to merge?

John Dlugosz
I'm merging two branches: let's say "dev" is for development of future
releases, and "rel" is changes made to the current release for immediate
application.  Now I want to bring the changes made in rel back to dev.

Rather than trying to merge it all at once, I'm applying the changes a
few at a time and making sure it still compiles as I go.  Then,
git-reset and I have dev as my HEAD and the desired merge result in the
working tree.

Now, I want to introduce the proper commit node to show that this is the
graft.  But, I don't want to be presented with all the differences that
I already resolved; I know what it should look like already.  How do I
commit the current state of things and have it show up with both dev and
rel as parents? (then make that the new dev)

I'm also interesting in learning how to do it better next time.  But I'm
doing the incremental merging now and need to know how to conclude it.

--John

TradeStation Group, Inc. is a publicly-traded holding company (NASDAQ GS: TRAD) of three operating subsidiaries, TradeStation Securities, Inc. (Member NYSE, FINRA, SIPC and NFA), TradeStation Technologies, Inc., a trading software and subscription company, and TradeStation Europe Limited, a United Kingdom, FSA-authorized introducing brokerage firm. None of these companies provides trading or investment advice, recommendations or endorsements of any kind. The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|

Re: proper way to merge?

John Tapsell
2009/2/27 John Dlugosz <[hidden email]>:

> I'm merging two branches: let's say "dev" is for development of future
> releases, and "rel" is changes made to the current release for immediate
> application.  Now I want to bring the changes made in rel back to dev.
>
> Rather than trying to merge it all at once, I'm applying the changes a
> few at a time and making sure it still compiles as I go.  Then,
> git-reset and I have dev as my HEAD and the desired merge result in the
> working tree.
>
> Now, I want to introduce the proper commit node to show that this is the
> graft.  But, I don't want to be presented with all the differences that
> I already resolved; I know what it should look like already.  How do I
> commit the current state of things and have it show up with both dev and
> rel as parents? (then make that the new dev)
>
> I'm also interesting in learning how to do it better next time.  But I'm
> doing the incremental merging now and need to know how to conclude it.

Instead of merge, I prefer to rebase.  so:

git checkout dev
git rebase origin rel

This replays each commit made in 'dev' on top of release, letting you
fix each commit separately.  It also means that when I commit to
release, the changes are a nice tree.

This only works if you have a relatively small number of changes.  I
tried to rebase 50 patches from 'dev' to 'rel' where the patches
changed pretty much every file.  It took all day to do.  (But it was
still better than trying to merge, in my specific case)

JohnFlux



>
> --John
>
> TradeStation Group, Inc. is a publicly-traded holding company (NASDAQ GS: TRAD) of three operating subsidiaries, TradeStation Securities, Inc. (Member NYSE, FINRA, SIPC and NFA), TradeStation Technologies, Inc., a trading software and subscription company, and TradeStation Europe Limited, a United Kingdom, FSA-authorized introducing brokerage firm. None of these companies provides trading or investment advice, recommendations or endorsements of any kind. The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to [hidden email]
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|

Re: proper way to merge?

Bryan Donlan
In reply to this post by John Dlugosz
On Fri, Feb 27, 2009 at 5:11 PM, John Dlugosz <[hidden email]> wrote:

> I'm merging two branches: let's say "dev" is for development of future
> releases, and "rel" is changes made to the current release for immediate
> application.  Now I want to bring the changes made in rel back to dev.
>
> Rather than trying to merge it all at once, I'm applying the changes a
> few at a time and making sure it still compiles as I go.  Then,
> git-reset and I have dev as my HEAD and the desired merge result in the
> working tree.
>
> Now, I want to introduce the proper commit node to show that this is the
> graft.  But, I don't want to be presented with all the differences that
> I already resolved; I know what it should look like already.  How do I
> commit the current state of things and have it show up with both dev and
> rel as parents? (then make that the new dev)
>
> I'm also interesting in learning how to do it better next time.  But I'm
> doing the incremental merging now and need to know how to conclude it.

So, if I understand correctly, you've manually applied (manually
applying diffs or something?) your changes from the release branch to
the dev branch, and now want to inform git of what happened?

If so, you could commit what you have now, use a graft to change its
parentage, then git-filter-branch to actually update the commit
object. Something like this, I believe:
git commit -m 'Merge .....'
echo '<full 40-character commit ID of the merge> <parent on the dev
branch> <parent on the release branch>' >> .git/info/grafts
git-filter-branch dev~..dev
## You can remove (that line from) .git/info/grafts now

In the future, you may want to perform this sort of incremental merge
by simply git merging intermediate revisions in the release branch.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|

RE: proper way to merge?

John Dlugosz
In reply to this post by John Tapsell
===Re:===
Instead of merge, I prefer to rebase.  so:

git checkout dev
git rebase origin rel

This replays each commit made in 'dev' on top of release, letting you
fix each commit separately.  It also means that when I commit to
release, the changes are a nice tree.
===end===

The reason I'm doing this -- why I took over maintenance of the repository -- is because I strenuously objected to his plan to "rebase".  NO!  Merge, don't rebase.  Besides never rebasing published branches, in this case it works much better the other way around:  dev made systemic changes, and rel is mostly patches and completely new pieces of code.  After looking at what was in dev..rel and what was in rel..dev, I chose to start with dev and bring in the commits from rel in a controlled manner.

I think you are indicated that the rebase is easier because the merge is done one commit at a time rather than in one huge bang.  I want to have that advantage and then some by picking related groups of commits and verifying that it still compiles before getting more, not even limited to the original order.

I'll post what I learned in a separate note.

--John
(excuse the footer; it's not my choice)


TradeStation Group, Inc. is a publicly-traded holding company (NASDAQ GS: TRAD) of three operating subsidiaries, TradeStation Securities, Inc. (Member NYSE, FINRA, SIPC and NFA), TradeStation Technologies, Inc., a trading software and subscription company, and TradeStation Europe Limited, a United Kingdom, FSA-authorized introducing brokerage firm. None of these companies provides trading or investment advice, recommendations or endorsements of any kind. The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.
N�����r��y���b�X��ǧv�^�)޺{.n�+����ا���ܨ}���Ơz�&j:+v�������zZ+��+zf���h���~����i���z��w���?����&�)ߢf�
Reply | Threaded
Open this post in threaded view
|

RE: proper way to merge?

John Dlugosz
In reply to this post by Bryan Donlan
===Re:===
So, if I understand correctly, you've manually applied (manually
applying diffs or something?) your changes from the release branch to
the dev branch, and now want to inform git of what happened?

If so, you could commit what you have now, use a graft to change its
parentage, then git-filter-branch to actually update the commit
object. Something like this, I believe:
git commit -m 'Merge .....'
echo '<full 40-character commit ID of the merge> <parent on the dev
branch> <parent on the release branch>' >> .git/info/grafts
git-filter-branch dev~..dev
## You can remove (that line from) .git/info/grafts now

In the future, you may want to perform this sort of incremental merge
by simply git merging intermediate revisions in the release branch.
===end===

That's very interesting.  I did not find 'grafts' in the documentation,
but I looked for it now that I know about it.  So you can add another
parent to the graph just by adding a line to that file.  BTW,
filter-branch isn't available on msysgit.  But leaving it in that grafts
file should be OK -- is that pushed/pulled with everything else?

--John


TradeStation Group, Inc. is a publicly-traded holding company (NASDAQ GS: TRAD) of three operating subsidiaries, TradeStation Securities, Inc. (Member NYSE, FINRA, SIPC and NFA), TradeStation Technologies, Inc., a trading software and subscription company, and TradeStation Europe Limited, a United Kingdom, FSA-authorized introducing brokerage firm. None of these companies provides trading or investment advice, recommendations or endorsements of any kind. The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|

proper way to merge?

John Dlugosz
In reply to this post by John Dlugosz
Thanks for the input, JohnFlux and Bryan.

Here's what I found worked.

First of all, the overall concept that changes to the repository are
never destructive (as long as you remember where you were) is
liberating.  It's beyond the confidence of an "undo" feature.  Really,
nothing I do can change any of the existing objects and their
interrelationship.  Using the reflog and lightweight tags, and the
feature that gitk still knows the nodes even after the labels move,
makes it easy to experiment on.

Basically, I cherry-picked the commits from "rel" to "dev" and fixed
them as I went.  Leaving it at that, I'd forever see duplicate commits
with the same comments but different actual commits, so things like "git
log here..there" will recognize the equality.

So, to make it look like I actually used the merge command, I did this:

1) I reset back to the original dev before my patching.  The default
reset, mixed, left the working tree unchanged and didn't do anything to
the index either.

2) git merge rel -s ours
That created a new node with the topology I wanted, but didn't actually
do anything.

3) add all the changed files, and "amend" the commit.


I suppose --no-commit would do the same thing as amending, but this way
I saw (in getk) that it really did what I wanted, instead of trusting
the multiple parentage to just be waiting somehow.

If keeping things in the working directory to carry between the steps
gives you the willies, remember that you can always reset --hard back to
where you were before doing (1).  Either because you tagged it just in
case, can find it using HEAD@{something}, or still see it on the screen
in gitk.

But, another approach would be to do the (fake) merge first, and then
keep amending it with the individual changes you pick from the other
branch.  I don't like that because the tree will show something that's
not true, until you are all done.  I want everything to be correct and
not lying if I get interrupted and leave it that way for a while.

Comments welcome.  I'm trying to get my act together before I start
evangelizing to the rest of the team.

--John
(excuse the footer; it's not my choice)

TradeStation Group, Inc. is a publicly-traded holding company (NASDAQ GS: TRAD) of three operating subsidiaries, TradeStation Securities, Inc. (Member NYSE, FINRA, SIPC and NFA), TradeStation Technologies, Inc., a trading software and subscription company, and TradeStation Europe Limited, a United Kingdom, FSA-authorized introducing brokerage firm. None of these companies provides trading or investment advice, recommendations or endorsements of any kind. The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|

Re: proper way to merge?

John Tapsell
In reply to this post by John Dlugosz
2009/3/2 John Dlugosz <[hidden email]>:

> ===Re:===
> Instead of merge, I prefer to rebase.  so:
>
> git checkout dev
> git rebase origin rel
>
> This replays each commit made in 'dev' on top of release, letting you
> fix each commit separately.  It also means that when I commit to
> release, the changes are a nice tree.
> ===end===
>
> The reason I'm doing this -- why I took over maintenance of the repository -- is because I strenuously objected to his plan to "rebase".  NO!  Merge, don't rebase.  Besides never rebasing published branches, in this case it works much better the other way around:  dev made systemic changes, and rel is mostly patches and completely new pieces of code.  After looking at what was in dev..rel and what was in rel..dev, I chose to start with dev and bring in the commits from rel in a controlled manner.

It depends on what you're doing :-)  I find that if the branch is too
large to easily rebase, then it's probably too large entirely :)
Developers don't like master to change in large ways suddenly - makes
it hard for all the other branches.

It also makes it impossible to bisect, something that I find
essential.  If you are combining two trees which are too big to easily
rebase, then there's a high chance that something will break either
due to their individual changes or because of a mistake while merging.
 In such a case, it's then impossible to bisect to try to pinpoint the
actual problem.

It will be interesting to hear your view on merging vs rebasing after
a year or so of trying both.

John
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|

Re: proper way to merge?

Johannes Sixt-2
In reply to this post by John Dlugosz
John Dlugosz schrieb:
> I did not find 'grafts' in the documentation,
> but I looked for it now that I know about it.  So you can add another
> parent to the graph just by adding a line to that file.  BTW,
> filter-branch isn't available on msysgit.

Huh? filter-branch *is* in msysgit. Why do you think it is not?

>  But leaving it in that grafts
> file should be OK -- is that pushed/pulled with everything else?

No.

You really want to use filter-branch if the new parent is to be permanent.

-- Hannes
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|

RE: proper way to merge?

John Dlugosz
===Re:===
Huh? filter-branch *is* in msysgit. Why do you think it is not?
===end===

Because when I tried it I got " git: 'filter-branch' is not a
git-command. See 'git --help'."
Then I looked in the Git installation directory and did not find any
file with that name.  Then I looked at the ReleaseNotes.rtf file in the
top of the Git installation tree and saw,
" * Some commands are not yet supported on Windows and excluded from
the installation; namely: git archimport, git cvsexportcommit, git
cvsimport, git cvsserver, git filter-branch, git instaweb, git
send-email, git shell, git svn."


So I wonder why you think it *is* in msysgit?  This is the latest
version from their site.

--John
(please excuse the footer; it's not my idea)

TradeStation Group, Inc. is a publicly-traded holding company (NASDAQ GS: TRAD) of three operating subsidiaries, TradeStation Securities, Inc. (Member NYSE, FINRA, SIPC and NFA), TradeStation Technologies, Inc., a trading software and subscription company, and TradeStation Europe Limited, a United Kingdom, FSA-authorized introducing brokerage firm. None of these companies provides trading or investment advice, recommendations or endorsements of any kind. The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|

Re: proper way to merge?

Johannes Sixt-2
John Dlugosz schrieb:
> " * Some commands are not yet supported on Windows and excluded from
> the installation; namely: git archimport, git cvsexportcommit, git
> cvsimport, git cvsserver, git filter-branch, git instaweb, git
> send-email, git shell, git svn."

A-ha. If there ever was a reason to exclude filter-branch, then I think
this reason is no more.

> So I wonder why you think it *is* in msysgit?  This is the latest
> version from their site.

Because I don't use the msysgit installer, but compile git myself. I have
a working filter-branch.

-- Hannes

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html