夜间模式
24. 溯源 blame
git blame [options] <file>
查看文件被谁修改以及提交信息等等
例子:
bash
$ git blame test.txt
86960c55 (yee1819 2024-05-15 08:53:55 +0800 1) 25616515
86960c55 (yee1819 2024-05-15 08:53:55 +0800 2)
074914c1 (yee1819 2024-05-15 09:37:42 +0800 3)
074914c1 (yee1819 2024-05-15 09:37:42 +0800 4) 这是在main分支输入的内容
336c576f (yee1819 2024-05-15 08:55:38 +0800 5) 这里是hello 分支的内容
074914c1 (yee1819 2024-05-15 09:37:42 +0800 6)
133c7fd3 (yee1819 2024-05-22 10:14:54 +0800 7) ttttt
133c7fd3 (yee1819 2024-05-22 10:14:54 +0800 8)
133c7fd3 (yee1819 2024-05-22 10:14:54 +0800 9) 6666
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
选项:
-L <start>,<end>
:限制只显示特定范围的行。shgit blame -L 10,20 <file>
1只显示从第 10 行到第 20 行的修改记录。
-c
:使用简短的提交哈希。shgit blame -c <file>
1-e
:显示作者的 email 地址。shgit blame -e <file>
1-f
:显示完整的文件名和行号。shgit blame -f <file>
1-l
:显示包含换行符的行。shgit blame -l <file>
1-p
:显示更详细的原始信息。shgit blame -p <file>
1--since=<date>
和--until=<date>
:限制显示从某个日期开始或截止的修改。shgit blame --since=2.weeks <file> 例如: $ git blame --since="2023-01-01" test.txt
1
2
3-C
:检测代码搬移(跨文件)。shgit blame -C <file>
1