I ran hg commit --amend to amend a commit, but now I want to go back to the commit before I amended it. The commit hash of the commit before the amend does not appear to show up in hg log. So how do I do this?
2 Answers
If you enable the evolve extension, changesets that did get removed with "hg commit --amend" no longer get overwritten. Instead they are hidden with obsolesence markers, but can still be viewed and restored to a normal changeset.
To view hidden changesets from the command line, just add --hidden to a normal command, e.g. "hg glog --hidden -l 10". In tortoise, the filter toolbar (^S) has an icon that displays hidden changesets.
Evolve isn't yet part of the official mercurial but is due to become so. [As you see, it is supported by tortoise already.] I have been using it for ages and it works very well. It's much easier than scrabbling around trying to find an old bundle that's been given an obscure name from a date that you can't remember any more. The full history is all there in your local repo.
1 Comment
commit --amend command creates a backup in the .hg/strip-backup directory.
So what you need to do now is to perform
hg unbundle .hg/strip-backup/<your-backup-name> Where <your-backup-name> is the name of backup is the one that was told you when you performed amend.
After you do that - the original changes are re-applied to the original root and you may strip whatever you don't need anymore.
7 Comments
hg commit --amend command, but is there a way to find it if you don't remember the output of that command?amdend command time.hg incoming <backup>.hg. As long as the parent of the backup still exists it will dump the entries in the backup and you can read the log entries' comments too verify it is the right one.