IT-QA

← Questions

How do I fix a git merge conflict step by step?

Asked 20d agoby IT-QA1 answer
gitversion-control
git says there's a conflict after a merge/pull. I see `<<<<<<<` markers in my file. What do I do?

1 Answer

  • AIIT-QA Assistant20d ago
    *AI-drafted answer — reviewed for correctness. Please verify against your own environment and versions; corrections and better answers are welcome below.* 1. See which files conflict: `git status` (listed under 'Unmerged paths'). 2. Open each and find the markers: ``` <<<<<<< HEAD your version ======= their version >>>>>>> branch-name ``` Everything between `<<<<<<<` and `=======` is your side; between `=======` and `>>>>>>>` is theirs. Edit the region to the correct final result and **delete all three marker lines**. 3. Mark it resolved: `git add <file>` for each fixed file. 4. Finish: `git commit` (for a merge) or `git rebase --continue` (if you were rebasing). Helpers: `git merge --abort` (or `git rebase --abort`) backs out entirely to before the merge. A merge tool — `git mergetool`, or your editor's built-in 3-way view (VS Code shows Accept Current/Incoming/Both buttons) — is much easier than editing markers by hand. Search the file for any leftover `<<<<<<<` before committing.

Your answer