I'm familiar with using git blame
on the commandline to show which commit changed a particular line of a file.
Is there a similar function to show which commit last changed the file "mode"/flags? E.g. setting or unsetting the executable flag.
You could use git log
with the --summary
flag and search the output for mode changes:
git log --summary -- path/to/file
From the documentation:
--summary
Output a condensed summary of extended header information such as creations, renames and mode changes.
With some grep
and head
:
$ git log --summary --format=%h | grep 'mode change' -m1 -B2 | head -1
It will print SHA-1
of last commit that contained mode change
. If you want to track a specific file:
$ git log --summary --format=%h <FILE> | grep 'mode change' -m1 -B2 | head -1
git log --summary --pretty=oneline | grep -B1 '^ mode change'
will give output like:
$ git log --summary --pretty=oneline | grep -B1 '^ mode change'
2edfdb6dd322d31818998fb4fb588394d57fd1b4 Remove executable flag
mode change 100755 => 100644 path/to/file
--
8b8c539cfaeda7f15be53839561dcae4f4a69f5e Make the file executable
mode change 100644 => 100755 path/to/file