🔀 Merge = Combine Changes
Branches diverge. git merge brings them together. Feature branch to main, bug fixes to release. Essential for collaboration.
📝 Basic Merge
# Switch to target branch git checkout main # Update main (pull latest) git pull origin main # Merge feature branch git merge feature-branch # Resolve conflicts (if any) # Edit files, git add, git commit # Push merged changes git push origin main
🎯 Merge Types
# Fast-forward merge (no merge commit) git merge --ff-only feature-branch # Create merge commit (always) git merge --no-ff feature-branch # Squash merge (one commit) git merge --squash feature-branch # Abort merge git merge --abort # Merge with commit message git merge feature-branch -m "Merge feature-branch into main" # Merge only specific files git checkout feature-branch -- file1.txt file2.txt
💡 Merge Conflicts
- Conflicts occur when same file changed differently
- Edit conflict markers (<<<<<<, =======, >>>>>>>)
- git add resolved files
- git merge –continue
- git merge –abort to cancel
“Merge brings branches together. Essential for team collaboration. Learn merge conflicts — they happen often.”

