commit to the wrong branch what to do

Alan Mackenzie acm at muc.de
Fri Sep 2 11:25:26 UTC 2016


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?

> Best wishes,
> Arne

-- 
Alan Mackenzie (Nuremberg, Germany).



More information about the Mercurial mailing list