Given a repository with commits:
git log
commit bbc190b20404548f356f38b0a377047efd13ae40 Author: Alice <alice@example.com> Date: Thu Mar 2 10:46:19 2023 +0100 Update file.txt commit 4273d9fd0f113258f2f2f5966771f3d5f84aff01 Author: Alice <alice@example.com> Date: Thu Mar 2 10:46:19 2023 +0100 Add file.txt
Use the --grep
option to select commits by message:
git log --grep="Update"
commit 3eb01e2c59d6240bb7b74c698ea4c95c5287ec65 Author: Alice <alice@example.com> Date: Thu Mar 2 10:48:02 2023 +0100 Update file.txt
The inverse also works.
Add the --invert-grep
flag to filter commits out by message:
git log --invert-grep --grep="Update"
commit f8255bebf8ab8124cd82f848b65d700dd34ef97d Author: Alice <alice@example.com> Date: Thu Mar 2 10:48:44 2023 +0100 Add file.txt