3 ms·
HEAD is always a reference to the checked out commit. A "branch" is a named reference to a commit to a commit that will auto advance if you check it out and mak
by Zambyte 3y ago
HEAD is always a reference to the checked out commit. A "branch" is a named reference to a commit to a commit that will auto advance if you check it out and make new commits. A tag is a named reference to a commit that will not auto advance if you check it out and make new commits.
If you checkout a commit using something other than a branch name, new commits that you make will not auto advance any branches. This is what a "detached HEAD" is, since your HEAD is detached from any branch.
- happytoexplain 3y agoYou're speaking at one level of abstraction up from the post you're replying to. You're both correct. It's just that you need to use the parent's level of abstraction if you want to strictly define "current branch".
- globular-toast 3y agoOne of the difficult things with git is it's hard to know which level of abstraction people are talking about. As I was typing my first comment I thought "well I guess a detached HEAD state is a branch too, as a branch is just a chain of commits". But that's at a completely different level of abstraction to where the OP is at. I would be at the "git as just a big ol' DAG" level but the OP is at the "git as a version control system" level.