4 ms·
The problem is that we, both people using git and teaching git, constantly say thing like “a commit is on this branch” or “we need to merge these branches” or e
by MatthiasPortzel 3y ago
The problem is that we, both people using git and teaching git, constantly say thing like “a commit is on this branch” or “we need to merge these branches” or even in the OP zine “you can remove commits from a branch.”
All of these phrases reinforce the common misconception that branches are “containers” for commits.
It would seem that you could query, “oh, what branch is this commit on?” But that’s not how git works. A commit has no idea what branch it is on, and that’s unintuitive. The only definition of being “on a branch” is, starting at the commit that the branch is currently pointing to, all ancestors of that commit are on the branch.
- rmwaite 3y agoI don't think it is inaccurate to say that a branch is a "container" for commits because a branch by definition points to a commit that has zero or more parent commits. Having to walk the commit ancestry to see if a commit is on a branch doesn't make it not true.