Does git (or need) have the equivalent of revising svn peg?

Let's 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 will need to use the peg revision syntax β€œ svn cat foo@1 ”, since the traditional syntax β€œ svn cat -r 1 foo ” will not be executed. I read that git tracks content, not files, does this mean that there is no need for something like a revision of the binding?

+7
source share
1 answer
 git show HEAD~1:/path/tp/foo 

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

As mentioned in Recover Deleted File in Git Repository , you can quickly restore a previous version of a file using checkout.

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

(with $file is the full path of the file from the root directory of the current Git repository).

+8
source

All Articles