Searching History
Find any commit.
After a year, a project might have thousands of commits. When you need to find one, scrolling isn't an option. Git log has powerful search options.

- Thousands of commits
- Scrolling won't work
- git log can search
Search messages and authors
Dash dash grep searches commit messages. Here, every commit mentioning contact. Dash dash author shows commits by one person. And dash dash since, with a date and time, shows only the commits made after it.
git log --oneline --grep contact 4a9b0f8 (HEAD -> main) Link to contact page f4ffcb2 Add contact form e45fb4b Add contact page git log --oneline --author "Sam" -n 3 4a9b0f8 (HEAD -> main) Link to contact page f4ffcb2 Add contact form e45fb4b Add contact page git log --oneline --since "2026-01-05 09:30" 4a9b0f8 (HEAD -> main) Link to contact page f4ffcb2 Add contact form e45fb4b Add contact page
Search the code itself
Even more powerful, capital dash S searches the changes themselves. It finds commits that added or removed some text. Which commit added the form? Dash S form tells us. It was add contact form. And git grep searches the files right now, showing every line that contains a word.
git log --oneline -S "<form>" f4ffcb2 Add contact form git grep -n contact index.html:4:<a href="contact.html">Contact</a>
Search options
Here are the search options together. Grep, for words in the message. Author, for a person. Since and until, for dates. Capital S, for text added or removed in the code. And a file name at the end, for one file's history.
| Option | Finds commits... |
|---|---|
| --grep word | with word in the message |
| --author name | by that person |
| --since / --until | in a date range |
| -S text | adding or removing text |
| -- file | touching that file |
Summary
Git log can search by message, author, date, code changes and file. Git grep searches your current files. Next, a popular style for commit messages.
Key takeaways- --grep, --author, --since
- -S finds code changes
- git grep searches files