Copyright (c) 2026 MindMesh Academy. All rights reserved. This content is proprietary and may not be reproduced or distributed without permission.
5.4.1. Branching Strategies and Merge Conflicts
Common Branching Models:
| Workflow | Description | Best For |
|---|---|---|
| Trunk-based | All changes go to main; short-lived feature branches | Fast-moving teams; CI/CD |
| Gitflow | main + develop + feature/release/hotfix branches | Scheduled release cycles |
| GitHub flow | main + feature branches + pull requests | Web applications; continuous deployment |
Merge Conflict Resolution:
# Conflict happens during merge
git merge feature-x
# AUTO-MERGING FAILED in file.txt — conflict markers inserted
# Conflict markers in the file:
<<<<<<< HEAD
current branch content
=======
incoming branch content
>>>>>>> feature-x
# Resolve: edit file, remove markers, keep desired content
vim file.txt
git add file.txt # Stage resolved file
git commit # Complete the merge
# Or use a merge tool
git mergetool # Opens configured merge tool
git config --global merge.tool vimdiff
# Abort a merge in progress
git merge --abort
Rebasing:
# Rebase rewrites history — use only on private branches
git rebase main # Apply current branch commits on top of main
git rebase -i HEAD~3 # Interactive rebase — squash, reorder, edit last 3 commits
# Interactive rebase options:
# pick — keep commit as-is
# squash — combine with previous commit
# edit — pause to amend commit
# drop — remove commit
# After rebasing, push requires force (history changed)
git push --force-with-lease origin feature-x # Safer than --force
Written byAlvin Varughese
Founder•18 professional certifications