Branching and merging
Another important feature of the Git version-control system is the option to create branches.
While working on software products, we often come across scenarios where we want to keep our production code base intact and then create a separate copy for adding features for handling bugs. A typical way of handling this is to create a copy of your entire code and then start making changes there. Once the changes are complete, we merge the copied code and the original version together. Using branches, we can do the same in an efficient manner.
In our previous examples, you must have seen the word master
branch. This is the default branch that is created when initializing a repository. Adding a branch will create a parallel version of the same code that can then be changed and later merged with the master
branch. There are several different practices when using branches. A branch can be created to fix bugs, add a feature, or even manage different versions.