DBedrenko
DBedrenko

Reputation: 5039

How to search changes with `git log` and show the matching lines?

I can use git log -G search_term to show the commits in which a line containing string search_term was added or removed, but this only shows metadata like the commit message and date, not the actual matching line.

I would like some output like:

some_hash: filename.c: + if search_term == True

Is this possible with the available options in Git without having to write a shell script?

Upvotes: 6

Views: 2417

Answers (1)

eckes
eckes

Reputation: 67177

You could display the full patch along with the log message by using -p:

git log -G search_term -p

Upvotes: 9

Related Questions