bashintermediate
Resolve Git Merge Conflicts
Step-by-step guide to identify, resolve, and complete merge conflict resolution in Git.
bashPress ⌘/Ctrl + Shift + C to copy
# Start a merge that may have conflicts
git merge feature/new-feature
# Check which files have conflicts
git status
# Conflict markers in files look like:
# <<<<<<< HEAD
# your changes
# =======
# incoming changes
# >>>>>>> feature/new-feature
# After manually resolving conflicts in your editor:
git add resolved-file.ts
# Complete the merge
git commit
# Abort the merge and go back to pre-merge state
git merge --abort
# Accept all incoming changes for a file
git checkout --theirs path/to/file.ts
git add path/to/file.ts
# Keep your version of a file
git checkout --ours path/to/file.ts
git add path/to/file.ts
# Use a merge tool
git mergetool
# View the base, ours, and theirs versions
git show :1:file.ts # base
git show :2:file.ts # ours
git show :3:file.ts # theirsUse Cases
- Resolving conflicts during branch merges
- Handling rebase conflicts step by step
- Team collaboration on overlapping code
Tags
Related Snippets
Similar patterns you can reuse in the same workflow.
bashintermediate
Git Merge Strategies — No-FF, Squash, Ours
Understand different merge strategies and when to use no-fast-forward, squash merge, and ours/theirs.
Best for: Choosing the right merge strategy for PRs
#git#merge
bashadvanced
Git Revert — Undo Merge Commits Safely
Revert merge commits safely without rewriting history, with options for parent selection.
Best for: Rolling back a broken deployment without force push
#git#revert
bashintermediate
Git Hooks Pre Commit
Git workflow: git-hooks-pre-commit
Best for: version control
#git#version-control
bashadvanced
Git Hooks Post Commit
Git workflow: git-hooks-post-commit
Best for: version control
#git#version-control