2

The closest answer is this one, and here's a line from it:

hg revert -r <oneRevBack> fileName

The last thing is to get <oneRevBack> other than using hash. I would dream of just typing <-1>.

Community
  • 1
  • 1
Dan
  • 52,315
  • 38
  • 111
  • 148

1 Answers1

5

The hg syntax for "one rev back" is tip^, where tip is the latest revision and ^ means "parent". If your working directory is not at tip, use .^, where the dot means "current revision".

Peter Westlake
  • 4,650
  • 1
  • 24
  • 35
  • Is there a way to go `n` commits back? – Dan Jan 07 '14 at 12:18
  • You can use `hg revert -r tip~n file` to revert to the n-th ancestor of the tip (using the first parent if a commit has two parents). See `hg help revsets` for more details. You can use `-(n+1)` only if there's only a single branch (-1 refers to the last revision, -2 the penultimate revision, and so forth, in order of revision numbering and not following the branch structure). – Reimer Behrends Jan 07 '14 at 13:40