4

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?

Gary
  • 3,891
  • 8
  • 38
  • 60

1 Answers1

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.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250