Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mercurial go back n revisions before the current one

Tags:

mercurial

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)?

like image 483
Will Hardwick-Smith Avatar asked Dec 29 '25 19:12

Will Hardwick-Smith


1 Answers

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.

like image 102
torek Avatar answered Jan 04 '26 17:01

torek



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!