How do I search git history for a disappeared line?

后端 未结 2 949
广开言路
广开言路 2020-12-13 05:51

I need to search the history of a specific file in a git repository to find a line that is gone. The commit message will not have any relevant text to search on. What comm

相关标签:
2条回答
  • 2020-12-13 06:34

    How about git log --stat | grep 'filename' to begin narrowing it down?

    0 讨论(0)
  • 2020-12-13 06:38

    This is a job for the pickaxe!

    From the git-log manpage:

    -S<string>

    Look for differences that introduce or remove an instance of <string>. Note that this is different than the string simply appearing in diff output; see the pickaxe entry in gitdiffcore(7) for more details.

    You can of course use further options to narrow it down, for example:

    git log -Sfoobar --since=2008.1.1 --until=2009.1.1 -- path_containing_change
    

    Isn't that awesomely useful?

    0 讨论(0)
提交回复
热议问题