tags:

views:

849

answers:

2

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?

+7  A: 

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

kaizer.se
hyggelig å kunne hjelpe
kaizer.se
+9  A: 

If you want to find all commits where commit message contains given word, use

$ git log --grep=word

If you want to find all commits where "word" was added or removed (to be more exact: where number of occurences of "word" changed), i.e. search the commit contents, use so called 'pickaxe' search with

$ git log -Sword
Jakub Narębski