How do they know which branch in my fork is mine vs upstream? Or in the case where I modify a forked branch?
So they just fake it: they look in their database to find any commit with that SHA and put it up. And that database happens (for obvious performance reasons) to be shared between a repo and its forks.
Including the id of the branch (the HEAD).
Just as a link in a linked list is often the list and the node in the list.