Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
3 views
in DevOps and Agile by (19.4k points)

In a Git code repository I want to list all commits that contain a certain word. I tried this

git log -p | grep --context=4 "word"

but it does not necessarily give me back the filename (unless it's less that 5 lines away from the word I searched for. I also tried

git grep "word"

but it gives me only present files and not the history.

How do I search the entire history so I can follow changes on a particular word? I mean to search my codebase for occurrences of word to track down changes (search in files history).

1 Answer

0 votes
by (27.5k points)

git log's pickaxe will find commits with changes including "word" with git log -Sword

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...