如何在gitk中仅显示指定作者提交并避免显示父提交?
Oh, I’ve run into this exact issue before! Let me break it down for you:
Why This Happens
Git’s commit history is built as a chain of snapshots linked by parent pointers, and gitk’s default behavior is to show all reachable commits for the ones you filter. When you use gitk --author="Your Name", gitk finds all your commits—but to keep the historical context intact (so you can see where your commits fit into the overall repo history), it automatically pulls in their parent commits, even if those parents weren’t made by you. It’s gitk’s way of making sure you don’t view your work in a total vacuum.
How to Only Show Your Own Commits (No Parent Commits)
You’ve got two straightforward ways to fix this, depending on whether you prefer the command line or gitk’s GUI:
1. Command Line Method
Use the --no-walk flag with your gitk command. This tells gitk to only display the exact commits that match your filter, not their ancestor commits:
gitk --author="Your Full Name" --no-walk
If you also want to cut down on merge commit noise (since their parents can add extra clutter), throw in the --no-merges flag too:
gitk --author="Your Full Name" --no-walk --no-merges
2. GUI Method (If Gitk Is Already Open)
If you’re already in gitk and want to adjust the view on the fly:
- Go to the top menu bar, click
View→New View - In the "Limit to:" text box, enter your author filter (e.g.,
author:"Your Full Name") - Check the box labeled Only show selected commits, not their history
- Click
OK—you’ll get a new tab with just your commits, no parent commit clutter
That’s all there is to it! Either method will let you focus solely on your own work without the extra historical noise.
内容的提问来源于stack exchange,提问作者Eugeniy Maksimov

