Is there a command in git to see (either dumped to stdout, or in $PAGER
or $EDITOR
) a particular version of a particular file?
views:
1697answers:
2
+12
A:
You can use git show
:
$ git show REVISION:path/to/file
For example, to show the 4th last commit of the file src/main.c
, use:
$ git show HEAD~4:src/main.c
For more information, check out the man page for git-show
.
mipadi
2008-12-03 19:46:52
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
2008-12-03 20:06:39
And if I just do "git-show path/to/file.c", the command succeeds with no output.
mike
2008-12-03 20:12:05
Yeah, I tried it out -- it worked for me.
mipadi
2008-12-03 22:13:01
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).
Dustin
2008-12-03 22:17:02
git version 1.5.6.3
mike
2008-12-03 22:33:46
Has to be the complete path, from the top of the git repo
rq
2008-12-04 08:25:12
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.
Matt McMinn
2010-07-21 14:56:56