In general, I'm sure some content was in a file, then got deleted sometime, I need to find out which commit made the change.
Say the content is "HelloWorld", the file is "DemoTest.json":
# To get only related commits
git log --oneline -G "HelloWorld" DemoTest.json
# Ignore case
git log -i --oneline -G "HelloWorld" DemoTest.json
# To get full contents of these commits
git log --follow -p -S "HelloWorld" DemoTest.json
Reference: How to grep (search) committed code in the Git history
网友评论