Script Valley
Developer Environment Setup (WSL, Terminal, VS Code)
Git Workflows and Developer Best PracticesLesson 6.3

How to resolve Git merge conflicts in VS Code

what causes merge conflicts, conflict markers, VS Code merge editor, accept current vs incoming vs both, git add after resolution, git merge --abort, preventing conflicts

Resolving Merge Conflicts

Git merge conflict resolution flow

A conflict occurs when two branches modify the same lines of a file. Git marks the conflicting sections and stops the merge โ€” you must resolve it manually.

What conflict markers look like

<<<<<<< HEAD (current branch)
return user.token;
=======
return user.accessToken;
>>>>>>> feature/auth-refactor

Everything between <<<<<<< and ======= is from your current branch. Between ======= and >>>>>>> is the incoming change.

Resolving in VS Code

VS Code shows inline buttons: Accept Current Change, Accept Incoming Change, Accept Both Changes, and Compare Changes. Click the appropriate option, or edit manually to create a combined outcome.

Completing the merge

git add src/auth.js
git commit

Abort a merge in progress

git merge --abort

Run this if you need to stop and rethink the merge strategy. It returns the repo to its pre-merge state.

Up next

How to use .gitignore to exclude files from version control

Sign in to track progress

How to resolve Git merge conflicts in VS Code โ€” Git Workflows and Developer Best Practices โ€” Developer Environment Setup (WSL, Terminal, VS Code) โ€” Script Valley โ€” Script Valley