nicely display file rename history in git log

Posted by Jian on Stack Overflow See other posts from Stack Overflow or by Jian
Published on 2012-11-19T04:56:29Z Indexed on 2012/11/19 5:00 UTC
Read the original article Hit count: 204

Filed under:

The git command

git log --format='%H' --follow -- foo.txt

will give you the series of commits that touch foo.txt, following it across renames.

I'm wondering if there's a git log command that will also print the corresponding historical file name beside each commit.

It would be something like this, where we can interpret '%F' to be the (actually non-existent) placeholder for filename.

git log --format='%H %F' --follow -- foo.txt

I know this could be accomplished with

git log --format='%H' --follow --numstat -- foo.txt

but the output is not ideal since it requires some non-trivial parsing; each commit is strewn across multiple lines, and you'll still need to parse the file rename syntax ("bar.txt => foo.txt") to find what you're looking for.

© Stack Overflow or respective owner

Related posts about git