updating across branches with local modifications (WAS: Why I Switched to Git from Mercurial)
Mike Meyer
mwm at mired.org
Sun May 23 07:47:57 UTC 2010
On Sat, 22 May 2010 22:27:07 -0700
Chad Dombrova <chadrik at gmail.com> wrote:
> in your translation you missed a step:
>
> $ git checkout HEAD^ -b feature
You're right - that does the right thing (i.e. - not what you
want). Apparently, hg only copies uncommitted changes if the place you
are updating to is an ancestor or descendant of the working copies
parent. Personally, I think it should always prompt you to merge
(maybe it ought to mention the -f flag), because you *are* doing a
merge, but an alias can arrange that for me. git, on the other hand,
does the merge, doing Linus-knows-what (hopefully) with the conflict
in the merge.
svn acts like git, and the only good that came of it for me is that I
now habitually check the status of my working copy before changing
branches. Because if those changes didn't belong in the new branch,
and I update to it and start working, I wind up with two sets of
changes that belong in two different branches. I can't even test them
properly, because my working copy has code in it that shouldn't be
part of the test, no matter which branch I'm working on.
Which leaves me with basically three choices (some with variations):
1) commit not-quite-ready code to one of the two branches; 2) move one
of the two patch sets to its proper branch outside the VCS; 3) commit
the entire mess to a third branch and cherry pick the changes from
that to the proper branches.
But gee, if I'd realized that I had uncommitted changes to start with,
I could have done any of those three things beforehand - only better
in two of the cases. There are extensions for doing option 2, and the
branch in option 3 only has changes for one branch, so it's a straight
merge with no cherry picking.
<mike
--
Mike Meyer <mwm at mired.org> http://www.mired.org/consulting.html
Independent Network/Unix/Perforce consultant, email for more information.
O< ascii ribbon campaign - stop html mail - www.asciiribbon.org
More information about the Mercurial
mailing list