CONFLICT (content): Merge conflict in src/app.js
Automatic merge failed; fix conflicts and then commit the result.
Two branches changed the same lines in the same file. Git can’t decide which version to keep, so it asks you to resolve it manually.
Fix 1: Read the Conflict Markers
// Git marks the conflict like this:
<<<<<<< HEAD
const port = 3000;
=======
const port = 8080;
>>>>>>> feature-branch
// <<<<<<< HEAD = your current branch
// ======= = divider
// >>>>>>> = the incoming branch
// Pick one, or combine them:
const port = process.env.PORT || 3000;
// Then delete ALL conflict markers
Fix 2: Resolve in VS Code
VS Code shows conflict markers with clickable buttons:
- Accept Current Change — keep your version
- Accept Incoming Change — keep their version
- Accept Both Changes — keep both
- Compare Changes — see side by side
Fix 3: After Resolving
# Mark the file as resolved
git add src/app.js
# Complete the merge
git commit
# Or if you want to abort the merge entirely
git merge --abort
Fix 4: Rebase Conflicts
# During rebase, resolve each conflict then:
git add .
git rebase --continue
# Or abort the rebase
git rebase --abort
Fix 5: Use Theirs or Ours
# Accept ALL changes from one side
git checkout --theirs src/app.js # Keep incoming
git checkout --ours src/app.js # Keep current
# For entire merge
git merge feature-branch -X theirs # Prefer incoming
git merge feature-branch -X ours # Prefer current
Fix 6: Prevent Conflicts
# Pull frequently to stay up to date
git pull origin main --rebase
# Communicate with your team about who's editing what
# Keep commits small and focused
Related resources
- Git cheat sheet
- Git merge conflict fix
- Git rebase conflict fix
- Git stash pop conflict fix Related: How to Undo the Last Git Commit
Related: Fix: fatal: not a git repository