Reputation: 4241
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?
Upvotes: 4
Views: 58
Reputation: 1326676
You could start with:
git log --oneline --name-only -M -C -- afile
That would detect any rename, and allow you to check if:
<commit>
is part of that listThen 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.
Upvotes: 1