Whenever a strip, amend or rebase operation is done, Mercurial automatically backs up the deleted commit in a bundle.
The backup bundles are in this directory: .hg/strip-backup.
The names of the backup files are based on the deleted commit’s changeset ID. If you don’t know that ID (you probably won’t because nobody usually writes down that ID before performing an operation), sort the contents of the directory by date. The suffix of the file name can guide you:
-amend.hg | bundles that contain the version of a commit before the amend operation |
-rebase.hg | bundles that contain the version of a commit before it was rebased |
-backup.hg | bundles that contain the commit that was deleted |
To restore the old commit, unbundle the backup file: $ hg unbundle .hg/strip-backup/example-backup.hg.
Note that the unbundle operation is safe. It will not overwrite the new version of the commit.