Explaining Git Merge and Conflicts to a 5 year old — Mitul Vaghela

Mitul Vaghela
2 min readMay 27, 2021
Git Merge and Conflict Resolution Photo by Yancy Min on Unsplash

Git merge and resolving resulting conflicts could be one hell of a concept to wrap your head around. In this short post, I have attempted to explain git merge and conflict resolution without use of technical jargon. The analogy takes inspiration from events of our day to day lives which, hopefully, everyone can relate to. In my experience, once you understand a concept fundamentally, you will always find it easier to understand in every other domain — in our case, git merge.

Picture this — you are planning a vacation with friends. You and one of your friends are in charge of making an itinerary and sharing it with all. After a high level plan, you and your friend prepare the itinerary and go over it.

While reviewing the itineraries, you find that there are some differences between your itineraries.

You added a visit to that picturesque park but apparently it is closed for maintenance. You had this on your itinerary but your friend knew about the closure and hence he planned a trip to the zoo. So, you remove the park and add the zoo to the final itinerary.

All of your friends love Italian food and both the itineraries have Italian dinners added. However, the restaurant on your itinerary offers vegan food while your friends do not. So, in the final itinerary you keep yours and remove your friend’s recommended restaurant.

Likewise, you go through both the itineraries, resolve all the conflicts and at the end you have one itinerary. That’s Git merge and conflict resolution for you. Whenever, you see merge conflicts, don’t be scared, go over the conflicts with fellow authors, discuss each change and accept the correct/best change.

Git merge illustration

But wait! This example has the potential to explain pull requests as well. Let’s say you guys have the final itinerary and you share it with all the friends. They review the itinerary and a friend suggests that you should rent that awesome convertible car when travelling to one of the destinations for best experience (optimal). You make that change and now you have the final and approved itinerary.

Originally published at http://mitulvaghela.com on May 27, 2021.

--

--