Reputation: 631
I was wondering if there is a way to view the commit information and the files changed in the commit when using grep.
To retrieve the commits when searching for a string in the commit messages I use:
git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --grep=<SEARCHING_STRING>
Then I get the commit id and use the following command to get all files changed under a commit:
git log --oneline --name-only | grep -Eo "\w/.*\.\w+" | sort -u --grep=<COMMIT_ID>
I'm trying to create a bash script to combine these two commands in only one and retrieve the commits and all files under a commit without success.
Upvotes: 2
Views: 72
Reputation: 2476
Use the --name-status
flag. Like:
git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --name-status --grep=<SEARCHING_STRING>
Upvotes: 1