因為在目前的程式碼裡找不到特定的字串,但是之前應該有,可能被移掉了,所以想找找之前提交的程式碼有沒有特定的字串。
請 Google 大神幫忙了一下,在 StackOverflow 上找到答案:How to grep (search) committed code in the git history? – Stack Overflow ,原來用 git grep 搭配 git rev-list 就可以做到:
# 找全部 git grep <regexp> $(git rev-list --all) # 只找特定目錄下的 git grep <regexp> $(git rev-list --all -- lib/util) -- lib/util