How to deny an old version, ignoring all versions after that

I have 3 commits that I accidentally pushed to a public repository. I want to revert to an older version (before these 3 commits happen) and make it the current code in our public repository. I am using TortoiseHg version 2.11.1

+3


source to share


2 answers


Option 1

You can use the strip option as specified in the hg command strip - command This extension must 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 you have access to a central repository where your code is hosted, and you have a small group where you will find out who has already made your changes.

Option 2

Another option would be to back up those 3 commits. Since you are using the UI, I will attach a screen shot

Step 1: right click on the unwanted commit and you will see the backup option click on it and the wll wizard will guide you through. if it is the merge you are trying to back up then you have to choose which branch to back up.

Do the same for 3 unwanted commits



enter image description here

Option 3

if you have a lot of commits and if its in a named branch following these steps will provide a solution

1) Close the branch and update to the latest required good commit. 2) Reopen bark from new commit (A named branch can have multiple heads) 3) use hg revert -r and commit

This will cause the working directory to exactly match the last good command you want, and ignore the associated commits. This will only work if the commits are on a named branch.

+2


source


You can do it like this:

hg backout -r <rev>
hg push

      



This will deviate from the version <rev>

(which should be the last correct commit). In other words, it will set your working directory to the same state as the last valid commit, and create a new commit with an explanatory message. Then you will pull it into the shared repository so that it plays the current code again.

0


source







All Articles