How to retrieve a single file from specific revision in Git?
the syntax is
(Although Mike Morearty mentions that, at least with git 1.7.5.4, you can specify a relative path by putting "
Before git1.5.x, that was done with some plumbing:
show a list of one or more 'blob' objects within a commit
cat a file as it has been committed within a specific revision (similar to svn cat). use git ls-tree to retrieve the value of a given file-sha1
original source : http://stackoverflow.com/questions/610208/how-to-retrieve-a-single-file-from-specific-revision-in-git
git show object
git show $REV:$FILE
git show somebranch:from/the/root/myfile.txt
git show HEAD^^^:test/test.py
The command takes the usual style of revision, meaning you can use any of the following:- branch name (as suggested by ash)
HEAD
+ x number of^
characters- The SHA1 hash of a given revision
- The first few (maybe 5) characters of a given SHA1 hash
git show
", always specify a path from the root of the repository, not your current directory position. (Although Mike Morearty mentions that, at least with git 1.7.5.4, you can specify a relative path by putting "
./
" at the beginning of the path -- for example:git show HEAD^^:./test.py
)Before git1.5.x, that was done with some plumbing:
git ls-tree <rev>
show a list of one or more 'blob' objects within a commit
git cat-file blob <file-SHA1>
cat a file as it has been committed within a specific revision (similar to svn cat). use git ls-tree to retrieve the value of a given file-sha1
git cat-file -p $(git-ls-tree $REV $file | cut -d " " -f 3 | cut -f 1)::
git-ls-tree lists the object ID for $file in revision $REV, this is
cut out of the output and used as an argument to git-cat-file, which
should really be called git-cat-object, and simply dumps that object to
stdout.original source : http://stackoverflow.com/questions/610208/how-to-retrieve-a-single-file-from-specific-revision-in-git
How to retrieve a single file from specific revision in Git?
Reviewed by (C#) Csharp examples
on
6:55 PM
Rating:
No comments: