Conflict Resolution
Preventing Conflicts
Best practices:
- Pull from main frequently (at least daily)
- Keep feature branches short-lived (< 1 week ideal)
- Communicate when working on shared files
- Break large features into smaller PRs
Resolving Merge Conflicts
When conflicts occur:
# Update the feature branch with main
git checkout main
git pull origin main
git checkout feature/your-feature
git merge main
# Git will mark conflicts in files
# Open conflicted files and resolve manually
# Look for conflict markers: <<<<<<<, =======, >>>>>>>
# After resolving all conflicts
git add .
git commit -m "merge: resolve conflicts with main"
git push origin feature/your-feature
Conflict resolution strategy:
- Understand both changes - what was each trying to do?
- Preserve both intentions when possible
- Test thoroughly after resolving
- Ask the other developer if uncertain
- Request re-review of PR after conflict resolution
Large Conflicts
If there are many conflicts:
- Consider rebasing instead of merging (discuss with team first)
- Pair with another developer to resolve together
- May indicate feature branch was too long-lived