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

后端 未结 15 1201

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:55

    If you want to browse code changes (see what actually has been changed with the given word in the whole history) go for patch mode - I found a very useful combination of doing:

    git log -p
    # Hit '/' for search mode.
    # Type in the word you are searching.
    # If the first search is not relevant, hit 'n' for next (like in Vim ;) )
    

提交回复
热议问题