Git log是否列出所有本地分支提交历史?如何查看单个分支日志?
Hey there! Let's break down your questions clearly:
1. Does git log list commit history for all local branches by default?
Nope, it doesn't. When you run a plain git log command without any extra options, it only shows the commit history of the branch you're currently checked out on (the one that shows up when you run git status).
If you do want to see commits from every local branch, you can use the --all flag:
git log --all
This will display commits from all your local branches, ordered by their commit timestamp (reverse chronological by default).
2. How to view commit logs for a single specific branch?
This is really simple — just pass the branch name directly to git log:
- For example, if your target branch is named
payment-integration, run:git log payment-integration
This will only show the commit history of that specific branch, starting from its most recent commit and working backwards.
You can also add handy flags to tweak the output:
git log --oneline payment-integration— condenses each commit to a single line with a short hash and message, perfect for a quick overview.git log --graph payment-integration— adds an ASCII graph to visualize how commits and merges fit into the branch's structure.
内容的提问来源于stack exchange,提问作者Rui




