4 ms·
Do you have an actual example of this? I've never encountered a situation where those three points are incorrect.
by sophacles 4y ago
Do you have an actual example of this? I've never encountered a situation where those three points are incorrect.
- badpun 4y agoGit branch is actually very similar to git tag[1]. For example, there are commands to point branch to completely different commit in different section of the commit graph, just like you can do it with tags. [1] The main difference perhaps is that, if you create a new commit, the branch pointer will actually be moved to point to that latest commit (while tag stays fixed).
- kleinsch 4y agoIf you're in a detached head state and create a new commit, you have a commit that isn't on a branch. The commit still has a parent, so it's not the branch that's tracking the sequence, it's the commit. Branches are just pointers that get updated as you add commits.
- sophacles 4y agoThis feels like declaring squares aren't rectangles because you can make rectangles that aren't a square.
- wonderbore 4y agoGit is only commits. Branches and tags are references to the commits; one moves while the other one doesn’t. That’s it. Commits link to their parent(s) until the initial commit. You can visualize a “branch” as a series of commits, but the same thing can exist without calling it a branch: A -> B -> C —> Initial Is that a branch? No. How about: /refs/heads/main = A That’s a branch, and it looks exactly the same as a tag: /refs/tags/v1 = A Neither a branch or a tag is “a series of commits” even if you think it does.
- deleted 4y ago[deleted]
- sophacles 4y ago> You can visualize a “branch” as a series of commits, but the same thing can exist without calling it a branch You can visualize a "square" as a rectangle with equal sides, but the same thing can exist without calling it a square.
- praptak 4y ago2. is true or untrue depending on how deeply you interpret it. A branch is named, points to a commit and under normal circumstances will track the sequence of commits made via itself (i.e. when you commit and HEAD points to branch b, b starts pointing to the child commit). So you could say it's a named sequence of commits. On the other hand you can reset the branch to any commit in the tree, even ones which aren't even on the current sequence of parents. It is still technically a named sequence of commits, just a totally different one.
- peter_t_wilson 4y ago
- stonemetal12 4y agoGit supports history rewriting so 1 isn't true. Git uses hashes for "unique ids" hashes aren't unique just low probability of collision, so 3 is also not true. Having run into issues that appear to be caused by 3 not being true, I don't see that as a theoretical issue.
- stu2b50 4y ago1 is true. When git is “rewriting” history it’s actually creating a new commits and moving the branch pointer over. Until the gc reaps them, you can absolutely git checkout the hash of any of the rewritten history and it’s still there, same as you left it. You can even move the branch pointer back, undoing the history rewrite.
- stonemetal12 4y agoSo when I do a pull I get their un-rewritten history? Just because they have a short undo buffer doesn't make modifiable history immutable.