Reputation: 107
I am trying to use 'git log --grep' to only return commits that starts with "word". I have tried 'git log --grep="word"'. However, this returns all commits that contain the string "word" anywhere in the commit message.
Upvotes: 1
Views: 917
Reputation: 2582
For all Windows command line users:
The approved answer wasn't working and even with '^' the word was searched somewhere in the commit message.
This worked for me:
git log --grep="^word" --extended-regexp
Upvotes: 0
Reputation: 13456
To grep all commits that start with word
, use:
git log --grep="^word"
Here ^
matches the start of the line.
To grep all commits that end with word
, use:
git log --grep='word$'
Here $
matches the end of a line.
To grep all commits that contains word
as substring, use:
git log --grep='word'
Upvotes: 1
Reputation: 301
The --grep option supports regex. So try the following command:
git log --grep="^word"
Upvotes: 3