Ravi
Ravi

Reputation: 3756

Does git have (or need) the equivalent of svn's peg revision?

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?

Upvotes: 8

Views: 740

Answers (1)

VonC
VonC

Reputation: 1324947

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

Upvotes: 9

Related Questions