Advanced Git Log Options Explained
In the last blog, we explored the basics of the git log command.
In this blog, we will continue and look at advanced options that make git log more powerful and useful in real-world projects.
Filtering Commits by Author
When multiple developers work on a project, you may want to see commits made by a specific person.
git log --oneline --author="Gaurav"
This shows only the commits authored by Gaurav. You can replace the name with any team member’s name.
Searching Commits by Message (grep)
You can filter logs by searching for keywords in commit messages.
git log --oneline --grep="modified"
Example output:
abc123 first file modified
def456 second file modified
This is useful when you want to track specific types of changes.
Viewing Commits Between Two Points
To see commits between two commit IDs:
git log <start-commit>..<end-commit>
Example:
git log abc123..def456
This shows all commits between abc123 and def456 (inclusive).
Viewing File Changes with Stats
To see which files were modified in each commit:
git log --stat --reverse
Example output:
commit abc123
1 file changed, 2 insertions(+)
commit def456
3 files changed, 5 insertions(+), 1 deletion(-)
This helps understand how many lines were added/removed per commit.
Visualizing Commit History with Graphs
Git can display logs as a text-based graph:
git log --oneline --graph
If your repository has branching and merging, this graph view is very helpful.
Summary
In this blog, we explored advanced Git log options:
- Filter by author →
--author="name" - Search by keyword →
--grep="keyword" - View commits in a range →
<start>..<end> - View stats of file changes →
--stat - Visualize commit history →
--graph
In the next blog, we’ll move on to the git diff command and learn how to compare changes.
Keep Learning 🚀
👉 Subscribe to Learning Ocean – Subscribers get coupon codes for my courses, early access to blogs and courses, and even exclusive YouTube videos.
👉 My YouTube Channel – More videos, more fun, and lots of learning!
👉 📺 Watch this topic in video form
Stay curious, keep coding, and let’s make learning fun together! 🎉