DEV Community

Anubhav Jain
Anubhav Jain

Posted on

Git

Git is probably one of the most used tools by programmers. While it is the most used tools, it is also a bit difficult to grasp by beginners. I wrote this tutorial in order to give you an overview of git and understand how to use its various features.

Suppose you work in a bakery making cakes for customers. The bakery here represents the organization you are working for. Now, you probably aren't the only one working there. There are others alongside you who make cakes as well. All the bakers use the bakery's common storeroom to get the ingredients required to make the cakes. The storeroom here represents the master code or the main code that everyone uses to develop new features or fix existing code.
Imagine how troublesome it will be if all the bakers took the same ingredients and started working on making the same cake all at once. Someone might add extra sugar or not add some other ingredient, resulting in a horrible tasting cake.
This is where the branching feature of git comes into play. All the bakers take the same ingredients from the store and start working on their individual cakes in their individual kitchens based on different customer's requirements. In other words, all the engineers are making changes to the same code without being affected by what others are doing. This in short, is what is probably the most famous feature git has to offer. If you are with me till now, keep reading!

Now, once the cakes are ready, we can't just send it out to the customers without any review. We take our peers' help to make sure the cake is beautiful to look at as well as the taste is up to the mark. This is what engineers do when they raise a pull request.
They ask their peers to review their code and suggest our changes before merging the code into a release branch. Once, it is in a release branch, it is tested once again to make sure we did not miss out on any issues that may pop up later and irritate the customer.

Now, how to make sure that our code is used up by other software engineers when they write new features to the codebase? We merge our branch with the master. Now, when someone uses the master code to start development. Our code will be present in there as well. Simple!

Top comments (0)