[英]How do you find out which commit a file mode change came from?
I'm familiar with using git blame
on the commandline to show which commit changed a particular line of a file. 我熟悉在命令行上使用
git blame
来显示哪个提交更改了文件的特定行。
Is there a similar function to show which commit last changed the file "mode"/flags? 是否有类似的功能来显示哪个提交最后更改了文件“mode”/ flags? Eg 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
标志一起使用,并在输出中搜索模式更改:
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
: 有一些
grep
和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
. 它将打印包含
mode change
的最后一次提交的SHA-1
。 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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.