Branching is often thought of as one of the best features of Git. Branching has made Git distinct from all other version control systems. It is very powerful and easy to use. Before we learn about the different branching commands, let me explain briefly how Git deals with commits, because that will help you understand Git branches. In Git, we already know that every commit has a unique hash, and that that hash is stored in the Git database. With the hash, every commit stores the hash of the earlier commit, which is known as the parent of that commit. As well as this, another hash that stores the files that were staged on that commit is also stored, along with the commit message and information about the committer and the author. For the first ever commit of a repository, the parent commit is empty.
The following diagram shows an example of hashing in Git:
We...