How to grep (search) committed code in the Git history

后端 未结 15 1232

I have deleted a file or some code in a file sometime in the past. Can I grep in the content (not in the commit messages)?

A very poor solution is to grep the log:

15条回答
  •  臣服心动
    2020-11-22 06:48

    Adding more to the answers already present. If you know the file in which you might have made do this:

    git log --follow -p -S 'search-string' 
    

    --follow: lists the history of a file

提交回复
热议问题