Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I just made a commit that I want to reverse, but I want to keep the bad commit in history. So, I hg update to the previous (good) commit. Then I keep working.

This leaves me with a new head: the abandoned bad commit.

Is this bad practice? What's the best way to keep bad commits in history while not using them?

share|improve this question

closed as off topic by dietbuddha, jk., Glenn Nelson, MainMa, Dynamic Mar 10 '13 at 3:02

Questions on Programmers Stack Exchange are expected to relate to software development within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

Yes it's a terrible idea, read more of the links in the answers below especially this:… – Warren P Mar 11 '13 at 13:19

If you don't want the branch you don't have to have it, use hg revert.

using revert will still keep the bad commit in history, it will create a new commit that undoes the changes from the bad commit.

share|improve this answer… gives the difference between the two if you want to know that – jk. Mar 9 '13 at 9:19
+1, and remember you can revert the revert if you want to bring the changes back again. – MattDavey Mar 9 '13 at 12:22
Is this the preferred way to keep bad commits? I guess I'm looking for best-practices; it seems like either way would work. – Tom Marthenal Mar 9 '13 at 19:18
yes id say it is preferred compared to branching (via update) – jk. Mar 13 '13 at 9:09

If you want to keep track of the mistake in the history you want to use backout. The backout command will create a new commit that cancel the previous one. You can even document why original commit is a mistake.

share|improve this answer
There are many reasons why adding extra heads is bad, it complicates or destroys ability to safely push/pull and merge for one thing. – Warren P Mar 11 '13 at 13:18

Not the answer you're looking for? Browse other questions tagged or ask your own question.