Merging
5 min read Quiz at the end
Merge branches with fast-forward, --no-ff, --squash strategies and resolve conflicts manually.
Merging Branches
# Merge feature into main
git switch main
git merge feature/login
# Merge strategies
git merge --ff-only feature # fast-forward only (no merge commit)
git merge --no-ff feature # always create merge commit
git merge --squash feature # squash all commits into one
# Resolve conflicts
# Edit files to fix <<<<<<< / ======= / >>>>>>>
git add resolved-file.txt
git commit
# Abort merge
git merge --abort
# View merge log
git log --merges
git log --graph --oneline
Topic Quiz · 1 questions
Test your understanding before moving on
1. What does git merge --squash do?
💡 --squash collapses all commits into staged changes; you then commit once with a clean message.