Is there a command in git to see (either dumped to stdout, or in $PAGER or $EDITOR) a particular version of a particular file?
From stackoverflow
-
You can use
git show:$ git show REVISION:path/to/fileFor example, to show the 4th last commit of the file
src/main.c, use:$ git show HEAD~4:src/main.cFor more information, check out the man page for
git-show.mike : That doesn't actually seem to work -- did you try it? For "git show HEAD:path/to/file.c", I get an "ambiguous argument" error.mike : And if I just do "git-show path/to/file.c", the command succeeds with no output.mipadi : Yeah, I tried it out -- it worked for me.Dustin : With what version of git? The other way to do it is with git cat-file given the blob ID (which you can find with ls-tree, but that's the hard way).mike : git version 1.5.6.3rq : Has to be the complete path, from the top of the git repoMatt McMinn : If you're on windows, it might be a path separator thing; if I do git show HEAD:dir\subdir\file, I get the anbiguous argument. If I do git show HEAD:dir/subdir/file, it works as expected. -
The path you must provide after the : is from the root of the git repository.
0 comments:
Post a Comment