7

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.

Armand
  • 23,463
  • 20
  • 90
  • 119

3 Answers3

6

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.

Eugene Yarmash
  • 142,882
  • 41
  • 325
  • 378
5

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
Arkadiusz Drabczyk
  • 11,227
  • 2
  • 25
  • 38
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
Armand
  • 23,463
  • 20
  • 90
  • 119