commit to the wrong branch what to do
Bob Hood
bhood2 at comcast.net
Fri Sep 2 13:18:56 UTC 2016
On 9/2/2016 5:25 AM, Alan Mackenzie wrote:
> On Fri, Sep 02, 2016 at 12:51:35PM +0200, Arne Babenhauserheide wrote:
>
>> Andreas Tscharner writes:
>>> On 01.09.2016 11:16, Uwe Brauer wrote:
>>>> Most likely this sometimes happens:
>>>> I added, removed, edited and then commit, but alas to the wrong branch.
>>>> What is the most efficient way to solve this issue?
>>> I would have taken
>>> hg graft
>>> and afterwards deleted/reverted the commit on the wrong branch
>>> hg help graft:
>>> copy changes from other branches onto the current branch
>> That’s what I recently did, too:
>> $ hg update right_branch
>> $ hg graft -r <REV>
>> $ hg update wrong_branch
>> $ hg backout -r <REV>
>> and then to avoid having to do it again:
>> $ hg update right_branch
>> :)
> That's all very well, but it's a poor solution to the OP's problem, as
> it leaves the repository polluted with two meaningless commits. Repo
> logs are difficult enough to read as it is, without this additional
> noise.
>
> Surely the solution has got to be to use $ hg rollback (assuming one
> notices one's mistake before doing anything else). Why is this
> essential command deprecated?
>
> Why is there not some command like rollback which can work on the latest
> commit to any branch? Is there something about the repository format
> that makes this impossible?
I'm using Mercurial 2.9.1 under Windows, and I have a command alias I use
called 'undomerge' to back out a bad merge:
hg rollback & hg update -C -r .
This works extremely well to remove the most recent merge to a working copy.
I'm surprised to hear that rollback is deprecated.
More information about the Mercurial
mailing list