Reputation: 2000
I have 3 commits which I pushed to the public repository accidentally. I want to revert to an older version (a version before these 3 commits happened) and make it the current code in our public repository. I am using TortoiseHg,version 2.11.1
Upvotes: 3
Views: 141
Reputation: 462
Option 1
You can use the strip option as mentioned in the command hg strip is the command This extension has to be enabled Enable the extension by adding the following lines to your .hgrc or Mercurial.ini: [extensions] strip = This option is only suitable if you have access to the central repository where your code is hosted and you have a small group in which you would know if someone have already pulled your changes.
Option 2
Another option would be to backout these 3 commits, Since you are using UI,I will attach a screen shot
Step 1: Right click the unwanted commit and you will see a backout option click that and the wizard wll guide you. if its a merge that you are trying to backout then you have to select which branch to backout to.
Do the same for the 3 unwanted commits
Option 3
if you have many commits and if its in a named branch following these steps will provide a solution
1) Close the branch and update to the last good commit you want. 2) Reopen the barch from there by new commit (Named branch can have multiple heads) 3) use hg revert -r and commit
This will make the working directory exactly as the last good commit you need and ignore the inwanted commits. This will only work if the commits are in a named branch.
Upvotes: 2
Reputation: 8754
You can do it like this:
hg backout -r <rev>
hg push
This will backout to the <rev>
revision (which should be the last correct commit). In other words, it will set your working directory into the same state as it was on the last correct commit and create a new commit with an explanatory message. Then you'll push it to the public repository so it's the current code again.
Upvotes: 0