git log 与 git log tag.. 输出不一致问题咨询
git log myTag.. Isn't Showing What You Expect Hey there! I totally get why this feels confusing—Git's range notation can be tricky when you first assume it's just a "time-based window" instead of what it actually is: a commit reachability filter. Let's break this down step by step.
First, What A..B Actually Means in Git
When you run git log myTag..HEAD (the HEAD is implied if you leave it off like git log myTag..), Git isn't showing you "all commits from myTag to now in chronological order." Instead, it's showing you every commit that is reachable from HEAD, but NOT reachable from myTag.
In plain terms: imagine your commit history is a tree. myTag points to a specific commit, and HEAD points to your current branch's tip. This command only shows commits that exist on your current branch's unique path that split off from the myTag commit—any commits shared between myTag and your current branch get excluded entirely.
Why This Contradicts Your Initial Expectation
When you run git log --oneline --decorate, you're seeing all commits reachable from your current HEAD, including those that are also reachable from myTag. So when you switch to git log myTag.., those shared commits disappear, making it look like the output is "missing" the stuff you expected.
For example:
- Suppose you tag main with
myTag, then create a feature branch, make 3 commits, and merge main into feature once. git log --oneline --decoratewill show your 3 feature commits, plus the merged main commits, plus everything back tomyTag.- But
git log myTag..will only show your 3 feature commits—because the merged main commits are still reachable frommyTag, so Git filters them out.
How to Get What You Actually Want
If you're trying to see all commits created after myTag was made (regardless of branch reachability), use a time-based filter instead:
git log --since="$(git show -s --format=%ci myTag)" --oneline --decorate
This grabs the timestamp of myTag and shows all commits made after that time.
If you do want the reachability-based range but want to visualize why some commits are excluded, add the --graph flag to see the commit tree structure:
git log --graph --oneline --decorate myTag..
This will make it obvious which commits are on your current branch's unique path vs. shared with myTag.
A Quick Reminder About git log Order
While git log defaults to showing commits in reverse chronological order (newest first), the range filter (myTag..) applies first. So even if a commit was made after myTag, if it's reachable from myTag (like a commit on the main branch after the tag), it won't show up in the range output.
内容的提问来源于stack exchange,提问作者JCollier

