Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TortoiseHG : Removing commit

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 ?

like image 947
deimus Avatar asked Sep 11 '12 14:09

deimus


3 Answers

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.

like image 104
Tim Henigan Avatar answered Sep 19 '22 17:09

Tim Henigan


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

like image 34
ScraperDave Avatar answered Sep 20 '22 17:09

ScraperDave


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

like image 29
andref Avatar answered Sep 19 '22 17:09

andref