How to get modify information of a renamed file in a specific commit?

Viewed 39

I want to get the modify information of a particular file(file_path) in a particular commit(commit_id). I know I can use git show commit_id file_path to achieve. But this method cannot handle the case when the file was renamed after that commit. For example, gr was renamed to gr1 in this commit.

So if I use git show --follow da2727b4556e19b873911ffaa6ae10043bb78715 gr1, there's no output. And if I use gr, git cannot find the path.

Now I can only use git show --follow da2727b4556e19b873911ffaa6ae10043bb78715 to get modify information of all changed files in that commit. I wonder if there's a method to get modify information of the particular renamed file? Thank you!

1 Answers

I'm not sure about git show (tried it), but I managed to get it to work with git diff on one of my repos with multiple edits in a commit. For it to work for you try:

git diff da2727b4556e19b873911ffaa6ae10043bb78715 -- gr

Note the double-hyphens before the list of files, and you must provide the full path working tree.

Related