Search code examples
gitmercurial

Mercurial equivalent to git's HEAD~1


In git it's quite convenient to identify a commit relative to the latest commit in the repo with HEAD~1.

I have searched and cannot find an equivalent for this in mercurial. I find mercurials revision numbers rather annoying.


Solution

  • There is a mercurial extension that adds git like commands.
    Specific command is hg log -pr .^1.

    For extra information, see examining a changeset in hg

    Edit: Use .^1, not tip^1. As mentioned below, tip gives the most recent commit in the entire repo, which is possibly not what you want. The . is closer in meaning to git's HEAD. (See also: Specify dot as a revision in Mercurial)