How to list only commits which was made after branch was splitted(checkouted)
To list only the commits made on your current branch after it split from a parent branch, use the double-dot (..) syntax with git log.
💻 The Best Commands
Run this command from your current branch:
git log main..HEAD
If you prefer a clean, single-line overview:
git log --oneline main..HEAD
(Note: Replace
main with master, develop, or whatever the name of your parent branch is.)🔍 How It Works
The
.. operator acts as a set subtraction tool. main..HEADmeans: "Show me all commits reachable fromHEAD(your current branch), but exclude any commits that are reachable frommain."- This leaves you exactly with the new commits added to your feature branch since the day you used
git checkout -b.
💡 Advanced Options
Depending on your workflow, you can add flags to handle specific scenarios:
- Exclude Merge Commits: If you have pulled or merged other branches into your feature branch and only want to see your unique work, add
--no-merges:git log main..HEAD --no-merges - Automatic Parent Tracking: If you don't want to type out the parent branch name every time, you can instruct Git to find the merge base automatically:
git log $(git merge-base main HEAD)..HEAD
If you want to view these changes in a visual graph to verify where the split happened, I can show you how to configure a graph view alias. Would you like to see that?
Comments