I know that to show a file at a certain commit, I use git show <commit>:<file path>
. But this doesn't work if the file was renamed between the commit and HEAD, so is there a way to easily do this on the file without needing to manually figure out what the original filename was at that commit?
Asked
Active
Viewed 51 times
4

Gary
- 3,891
- 8
- 38
- 60
1 Answers
1
You could start with:
git log --oneline --name-only -M -C -- afile
That would detect any rename, and allow you to check if:
- your
<commit>
is part of that list - what is the actual name associated with that commit
Then you can use the right filename for git show <commit>:<file path>
.
Note, in git 2.9 (June 2016):
So make sure to use git 2.9 as well.
-
Did you mean `git log` here? – torek Jun 19 '16 at 07:23
-
@torek Actually, I tested it with `git show` (since it uses the same options as `git log`), but yes, `git log` is more logical. – VonC Jun 19 '16 at 07:24