🚀 DevOps Day 11 — Git Merge, Rebase & Pull Request Workflow (Real DevOps Flow)

Welcome to Day 11 of the DevOps Series.

In the previous blog, we learned about Git branching strategies.

Today, we’ll understand how code actually moves between branches using:

  • Git Merge

  • Git Rebase

  • Pull Request (PR) workflow

These concepts form the real DevOps development flow followed in organizations.


🔁 Why Merging Is Required

In real projects:

  • Developers work on feature branches

  • Main branch contains stable code

Once a feature is completed and tested, it must be combined back into the main branch.

This process is called merging.


🔀 Git Merge

Git merge is the safest and most commonly used method.

Example:

git checkout main git merge feature/login

What happens?

  • Git combines feature branch changes into main

  • Creates a merge commit

  • Preserves complete history

Advantages:

  • Safe

  • Easy to understand

  • Used in most enterprise projects

Disadvantage:

  • Commit history can become messy in large projects


🔄 Git Rebase

Rebase is used to rewrite commit history.

Example:

git checkout feature/login git rebase main

What happens?

  • Feature branch commits are replayed on top of main

  • History becomes linear

  • No merge commit created

Advantages:

  • Clean commit history

  • Looks professional

Disadvantages:

  • Dangerous if used incorrectly

  • Should NOT be used on shared branches

👉 Rule:

Rebase local branches, merge shared branches.


⚔️ Merge vs Rebase (Simple Comparison)

FeatureMergeRebase
HistoryPreservedRewritten
SafetyVery safeRisky if misused
Common usageTeam branchesLocal cleanup
Recommended for beginners✅ Yes⚠️ Use carefully

🔐 What Is a Pull Request (PR)?

A Pull Request is a request to merge code from one branch into another.

Used mainly in:

  • GitHub

  • GitLab

  • Bitbucket

It enables:

  • Code review

  • Automated testing

  • Team discussion

  • Approval-based merging


🔄 Real DevOps Pull Request Workflow

Step 1️⃣ Developer creates feature branch

git checkout -b feature/payment

Step 2️⃣ Code is written and committed

git add . git commit -m "Add payment feature"

Step 3️⃣ Push branch to GitHub

git push origin feature/payment

Step 4️⃣ Create Pull Request

  • Source: feature/payment

  • Target: main

Step 5️⃣ CI/CD pipeline runs

  • Build

  • Test

  • Lint

  • Security checks

Step 6️⃣ Code review

  • Team reviews changes

  • Suggestions provided

  • Changes updated if required

Step 7️⃣ Merge PR

  • Merge commit created

  • Feature branch deleted

This is the standard DevOps workflow followed in companies.


🧠 Why Pull Requests Are Important in DevOps

Pull Requests help in:

  • Preventing broken production code

  • Enforcing code quality

  • Enabling collaboration

  • Triggering automated pipelines

  • Maintaining audit history

Most organizations do not allow direct push to main branch.


🌍 Real-World DevOps Flow Summary

Feature Branch ↓ Pull Request ↓ Automated CI Checks ↓ Code Review ↓ Merge to Main ↓ Deployment Pipeline

This flow ensures:

  • Stability

  • Speed

  • Quality

  • Accountability


✅ Summary



On Day 11, we learned:

  • What Git merge is

  • What Git rebase is

  • Difference between merge and rebase

  • What a pull request is

  • Real DevOps Git workflow used in companies

“DevOps is not just tools — it’s disciplined collaboration.”

Comments

Popular posts from this blog

🧩 DevOps Day 1 — Fundamentals of DevOps

DevOps Day 23 — Multi-Stage Docker Builds & Distroless Images: Build Smaller, Safer Containers

🚀 DevOps Day 2 — Understanding the SDLC and the Role of DevOps Engineers