Skip to main content

Command Palette

Search for a command to run...

🪶 Git Day 3: Branches & Merge Conflicts – A DevOps Story from the Coconut Grove 🌴

Published
4 min read
🪶 Git Day 3: Branches & Merge Conflicts – A DevOps Story from the Coconut Grove 🌴

“When code meets conflict, a wise developer doesn’t panic — they branch out.”

Vanakkam, techies! 👋
Welcome back to Day 3 of our Git Mastery Series.
If you’ve followed Day 1 (Git basics) and Day 2 (commits, logs, and remotes), today is where the real fun begins — branches and merge conflicts.

But before we dive into code, let me take you on a short story from our land…


🌾 The Story of Two Farmers (A Simple Analogy for Git Branches)

In a small South Indian village named TiruCodePuram, two farmers — Ravi and Anbu — share a piece of farmland (the main branch 🌿).

One day, Ravi says:

“Let’s try planting coconuts 🌴 in half of it.”

Anbu replies:

“Okay! But I’ll try bananas 🍌 in my part.”

So they both start working separately
Ravi creates a new path for coconuts (that’s a branch),
and Anbu continues on the main path.

Later, when both are happy with their crops, they combine their results.
That’s what we call a merge in Git.


⚙️ Technical Translation

In Git terms:

ConceptStory EquivalentGit Command
Main branchThe original farmlandmain or master
New branchRavi’s coconut patchgit branch coconut
Switching to branchMoving to that fieldgit checkout coconut
MergingCombining both cropsgit merge coconut
Merge conflictWhen banana roots mix with coconuts 😅Resolve manually

💻 Step-by-Step Hands-on Demo

Let’s recreate Ravi and Anbu’s farm — Git style!

🥥 Step 1: Initialize a Repo

mkdir git-day3-demo
cd git-day3-demo
git init
echo "Main Farm: Bananas" > farm.txt
git add .
git commit -m "Initial commit - main farm with bananas"

🌴 Step 2: Create a New Branch

git branch coconut
git checkout coconut

Now you’re working in the coconut branch.

🍌 Step 3: Make a Change in the Branch

echo "Coconut trees planted 🌴" >> farm.txt
git add farm.txt
git commit -m "Added coconuts"

🏠 Step 4: Switch Back to Main Branch

git checkout main

Now modify the main branch too:

echo "Banana trees growing 🍌" >> farm.txt
git add farm.txt
git commit -m "Bananas are growing well"

⚡ Step 5: Merge and Watch the Conflict

Now, try merging coconut branch into main:

git merge coconut

Uh oh 😬
Git will say:

CONFLICT (content): Merge conflict in farm.txt
Automatic merge failed; fix conflicts and then commit the result.

🧩 Step 6: Resolving the Merge Conflict

Open farm.txt — you’ll see something like:

Banana trees growing 🍌
<<<<<<< HEAD
Main Farm: Bananas
=======
Coconut trees planted 🌴
>>>>>>> coconut

These are Git’s conflict markers:

  • <<<<<<< HEAD → changes from your current branch (main)

  • ======= → separator between both branches

  • >>>>>>> coconut → changes from the branch being merged

Now, let’s manually combine the best of both worlds:

Main Farm: Bananas
Banana trees growing 🍌
Coconut trees planted 🌴

Save it, then:

git add farm.txt
git commit -m "Resolved conflict: merged banana and coconut farm"

🎉 Congratulations! You’ve just resolved your first merge conflict like a pro DevOps engineer.


🧠 Pro Tip: Visualizing Branches

git log --oneline --graph --decorate --all

You’ll see a beautiful tree-like structure showing where branches diverged and merged.


🚀 Real DevOps Example

Imagine your main branch runs production code,
and your feature/login-ui branch is under development.

When multiple developers merge changes into the same files — especially configuration or frontend files — merge conflicts happen.

✅ Best practices:

  • Always pull before you start work: git pull origin main

  • Use feature branches for isolated development

  • Review changes using pull requests

  • Communicate with your team — conflicts are not bugs, they’re conversations between developers 😉


💬 In the Words of a South Indian Grandmother 👵

“When two cooks add salt at the same time, the curry becomes salty.
But when they talk, the dish becomes perfect.”

That’s what merge conflicts teach us — coordination and clarity.


🔚 Wrapping Up

Today we learned:

  • How to create and switch branches

  • How to merge branches

  • How to handle merge conflicts like a pro

  • And how storytelling makes Git memorable 😄

In the next blog (Day 4), we’ll explore Git Remote Branches, Pull Requests, and Rebase — the art of keeping your repository clean.

More from this blog

thiru's blog

43 posts