Q: Does a commit know its children? - detached HEAD Do I understand what's detached HEAD is all about in GIT? I see it as follows.
HEAD points to the currently active branch. If I checkout (select) an earlier commit in the branch, HEAD's will store the hash of that commit (instead of branch name) - this is the situation called 'detached HEAD'. Now suppose I added a few commits after doing that and checkout back the master branch (that's where I was at the beginning).
Now, what's the exact reason I've lost the commits I'd just made?
Is it because the commits only know its parents, not children? The solution is to create a new branch in detached HEAD state before doing commits, right? This way I'll be able to reference to the new commits made from that point.
Interesting source

A: The exact reason the new commits were lost is because by creating them in detached HEAD mode, there is no commit or tag that references them.  Thus they cannot be found by log, for example.
To track the new commits you can create a new branch in detached HEAD state either before or after you have made additional commits.  Alternatively you could tag the final commit before running checkout to switch back to master.
Note that the commits are not truly lost - not immediately at least.  The reflog will have a record of where HEAD pointed at all times, even when not on a branch.  However, after a long time it is possible that the unreferenced objects will be garbage collected to save space in the repository.
