TortoiseHG : Removing commit
Asked Answered
C

3

10

I've accidentally committed bunch of files locally, but didn't pushed. So basically what I want to do is to remove this my commit, then push some other changes.

I can remove the commit by Backout-ing, then I've to commit locally so it is actually removed locally.

So my question is following, if I do a push, will my accidental commit and its corresponding revertion log be visible publically ?

Chilpancingo answered 11/9, 2012 at 14:58 Comment(0)
F
18

It sounds like hg rollback is the command you want.

hg backout <REV> creates a new commit that reverses the changes made in <REV>. Both the original commit and the backout commit will remain in your history. This is one of the few options you have to fix a bad commit after you have pushed it to a public location.

However in this case you have not pushed to the public yet, so there are better solutions.

If the bad commit is the last commit that was done (i.e. your tip) then you can use hg rollback (under the Repository menu in TortoiseHg). This command is like "undo" for commits.

If the bad commit is elsewhere in your history (but still has not been pushed to a public repo), you can also use the mq extension to rewrite that part of your history.

Fibroblast answered 11/9, 2012 at 17:17 Comment(2)
hg rollback is deprecated.Lunalunacy
I did a bad merge, with another branch, and tried hg backout <REV> getting, abort: cannot backout a merge changeset. Is there any way to fix itMass
L
3

You could use hg strip -r . --keep instead of hg rollback. hg backout would be necessary only if you had pushed your commits.

Lunalunacy answered 28/10, 2014 at 18:15 Comment(0)
L
1

The simple answer to your question is Yes.

If you perform a Backout, then it will show up in your history.
You want to perform a Strip, as previously suggested.

This is an extension to mercurial.
https://www.mercurial-scm.org/wiki/StripExtension

Ly answered 26/1, 2017 at 5:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.