In my last blog, We learned about version control and its use in software development. We also understood some of the basic git commands like config, clone, commit, and push. As a beginner both in git and a project, these commands come in handy and get us going.

As we grow and our project grows, so does the team. With all the growth, it becomes tough for developers to manage code and keep track of all the contributions. This is where branching comes into the picture.

What is a branch?

In Git, a branch is a new/separate version of the main repository. It represents an independent line of development. It also serves as an abstraction for the edit/stage/commit process, meaning that whatever changes you make in a branch do not affect your master/main [T&C Apply].

Some Branching commands

Well... That was a lot of branching knowledge, and contrary to the law of conservation of energy, a branch can be created or destroyed (deleted), and the only way to preserve it is to merge it to master or to its target finally.

What is a merge?

Merge is the process of taking the contents of a source branch and integrating them with a target branch.

Remember the T&C I had put earlier? It's time we trace back.

Let's get into a scenario where you were given a feature to implement i.e., Heart Glasses for your octopus (Here onwards, we will call him Octie). What will you do?

The below image practically sums up the whole process -

Some merge git commands

In this blog post, we have deep-dived into branching and merging, and we are one step closer to becoming git masters.

In the next blog post, we will try to cover resetting a branch, tagging, and so much more. I also intend to cover some less-known git features in this series. Do you know you can clone only a subdirectory from a git repo? More on this later!

Stay tuned, follow me on social media channels, and subscribe to my newsletter to get updates on my upcoming posts.

Feel free to comment on how you like my blog on the system design series or shoot me an email at [email protected]. If you have any queries, I will try to answer them.

You can also visit my website to read some of the articles at https://nandan.dev/

Stay tuned & connect with me on my social media channels. Subscribe to my newsletter to get regular updates on my upcoming posts.


Also published here.