The key item you're getting to here—the source of your question—is that branch names don't mean much at all, in Git. They are just moveable pointers that, by definition, point to the last commit in a branch. Multiple names can point to any single commit.
In Git, it's the commits that matter. The commit is Git's raison d'être. Commits acquire a hash ID simply by being created, because, like all of Git's four object types, the hash ID is the cryptographic checksum of the commit's content. Since each commit is unique—it has a timestamp to help out, in case everything else about the commit is the same as some earlier one—each commit acquires a new, unique hash ID.
However, commit hash IDs are seemingly random and impossible for humans to remember or work with. So we need some way to name the latest commit that we want to remember. That way is, generally, with a branch name. Once we have a commit, we can point any number of branch names at it.
Each commit remembers its parent or parent hash IDs, so we only need to remember the last, or tip, commit of the branch—all the earlier ones are find-able by starting at the end and working backwards. So the branch name identifies the tip commit, only.
When Git creates a new commit, Git simply writes the new commit's hash ID into the current branch. Which branch is the current branch? The answer to that is equally simple: the special name HEAD
holds the name of the current branch.
It's important to make sure that any useful Git commit is reachable by some name, because Git will eventually garbage collect any unreachable commits. That is, if the name xyz
identifies commit a123456...
, that commit is protected from the garbage collector. So it that commit's parent (or parents), and grandparents, and so on. Git give you some time (14 days, by default) to hook things up so that objects, including commits, are protected through this reachability idea: you first create an object, such as a blob or tree or commit, then update any name(s) needed to be able to find the object and any of its ancestry. The 14 day window is your grace period to complete the name-updating, after creating the object(s).