【问题标题】:How to find the diff history of specific line in a file using git?如何使用 git 查找文件中特定行的差异历史记录?
【发布时间】:2015-12-15 00:48:52
【问题描述】:

例如,我想查找文件中特定行的历史列表

file: something.txt

1/2
line 1: // change comment to 1

2/15
line 1: // change comment to 2

12/15
line 1: // change comment to 4

如果我执行git blame,它只会显示12/15 条目,如果2/1512/15 之间有大量提交,那么git log 并不是很有用

谁能给我一些建议?

谢谢

【问题讨论】:

    标签: linux git command-line command


    【解决方案1】:

    你的例子:

    git log -L 1,1:something.txt
    

    来自documentaion

    -L ,:

    -L ::

    跟踪 中“,”(或函数名正则表达式 )给出的行范围的演变。您不得提供任何路径规范限制器。这目前仅限于从单个修订开始的步行,即,您只能给出零个或一个积极的修订参数。您可以多次指定此选项。

    【讨论】:

      猜你喜欢
      • 2018-11-01
      • 2022-01-10
      • 1970-01-01
      • 2010-12-19
      • 2017-07-02
      • 2019-12-01
      • 2012-08-10
      • 2017-12-27
      • 1970-01-01
      相关资源
      最近更新 更多