7

Say I follow these steps in svn:

rev 1: create a file called 'foo'
rev 2: delete 'foo'
rev 3: create a new file called 'foo'

If I want to see the contents of the first 'foo' using svn, I would need to use the peg revision syntax 'svn cat foo@1' since the traditional syntax 'svn cat -r 1 foo' would fail.
I've read that git tracks content and not files, so does that mean there's no need for something like a peg revision?

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
Ravi
  • 3,718
  • 7
  • 39
  • 57

1 Answers1

8
git show HEAD~1:/path/tp/foo

will show you the content of the file as it was in "rev1" (note: you need to specify the full path of the file, from the root directory of the Git repo)

As mention in "Restore a deleted file in a Git repo", you can quickly restore a previous version of a file with a checkout.

git checkout $(git rev-list -n 1 HEAD -- "$file")^ -- "$file"

(with $file being the full path of the file from the root directory of the current Git repo.)

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 6
    Basically git always does the equivalent of `svn cat foo@1`. Linus would probably consider the behavior of `svn cat -r 1 foo` to be yet another one of svn's failures. (I do too) – Arrowmaster Jan 30 '11 at 02:12