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.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…