In mercurial how can I go back n revisions from the revision I'm currently on?
This answer shows how it can be done in git: https://stackoverflow.com/a/16739578/1696114, git checkout HEAD~n.
If there isn't a way to go back n revisions, is there a way to go back just to the parent revision (i.e. one revision back)?
Instead of HEAD~n, use .~n.
hg help revisions shows you Mercurial's revision specifiers.
The Mercurial equivalent of Git's HEAD/@ is ., and the Mercurial equivalent of Git's ~number is ... ~number 😀
Like Git, Mercurial also supports the ^ suffix, with the same meaning: ^ followed by a number is the number-th parent.
Omitting the number gets you the first parent, or steps back 1 first-parent (which gets you the first parent), so .^ or .~ gets you the first parent. Note that some Windows command line interpreters like to use ^ for their own purposes so that you may have to quote them.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With