How to show a file from a specific commit that has been renamed between this commit and HEAD?

I know that to display a file with a specific git show <commit>:<file path> I use git show <commit>:<file path> . But this will not work if the file was renamed between commit and HEAD, so is there a way to do this in the file without having to manually determine what the original file name is with this commit?

+5
source share
1 answer

You can start with:

 git log --oneline --name-only -M -C -- afile 

This will detect any renaming and allow you to check:

  • your <commit> is part of this list
  • what is the actual name associated with this commit

Then you can use the correct file name for git show <commit>:<file path> .

Please note that in git 2.9 (June 2016):

So be sure to use git 2.9.

0
source

All Articles