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
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-refactorEverything 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 commitAbort a merge in progress
git merge --abortRun this if you need to stop and rethink the merge strategy. It returns the repo to its pre-merge state.
