Reputation: 380
This might be a default behavior but it's giving me hard time to understand. I always thought a branch must be one line, without other "branches". I made the following experiment:
Now the branch looks like below
From my understanding, there are 4 checkins in master branch, 2 checkins in dev branch.
Now I perform the following operations:
The branch looks like below:
I would think that the master branch is the green one, it contains 5 commits. The dev branch is the purple one, it contains 4 commits.
Actually, in master branch, I use git log
to check the commits, it actually has 7 commits. Which confuses me.
Can someone help explain?
Upvotes: 0
Views: 37
Reputation: 21918
git log
lists all commits reachable from the given ref (or HEAD if no refs are given). The 7 commits you see are reachable. You might need to give log some other specific parameters if you want to see only parts of the tree. (Check the doc there are great examples)
Also, your surprise can be a consequence of a misunderstanding about branches in git. No commit in the tree belongs to any branch. The whole tree can be accessed through different points, and branches are just shortcuts to point at one commit.
Upvotes: 1