Git and SSH

Fix a merge conflict

Git found two changes to the same lines and wants you to choose. Here's how to finish the merge.

Fill these in once
  1. See which files clash
    Terminal
    git status

    They're listed under “Unmerged paths”.

  2. Open each file and choose
    Terminal
    git diff

    Each clash sits between <<<<<<< and >>>>>>>. Keep the lines you want and delete the markers.

  3. Mark the file as fixed
    Terminal
    git add index.html
  4. Finish the merge
    Terminal
    git commit --no-edit

Check it worked

  1. Check nothing is left
    Terminal
    git diff --check

    Nothing is printed when every marker is gone.

Undo it
  1. Give up and go back
    Terminal
    git merge --abort

    Cancels the whole merge. Nothing is lost.

  1. See which files clash
    Terminal · Ubuntu / Debian
    git status

    They're listed under “Unmerged paths”.

  2. Open each file and choose
    Terminal · Ubuntu / Debian
    git diff

    Each clash sits between <<<<<<< and >>>>>>>. Keep the lines you want and delete the markers.

  3. Mark the file as fixed
    Terminal · Ubuntu / Debian
    git add index.html
  4. Finish the merge
    Terminal · Ubuntu / Debian
    git commit --no-edit

Check it worked

  1. Check nothing is left
    Terminal · Ubuntu / Debian
    git diff --check

    Nothing is printed when every marker is gone.

Undo it
  1. Give up and go back
    Terminal · Ubuntu / Debian
    git merge --abort

    Cancels the whole merge. Nothing is lost.

  1. See which files clash
    PowerShell
    git status

    They're listed under “Unmerged paths”.

  2. Open each file and choose
    PowerShell
    git diff

    Each clash sits between <<<<<<< and >>>>>>>. Keep the lines you want and delete the markers.

  3. Mark the file as fixed
    PowerShell
    git add index.html
  4. Finish the merge
    PowerShell
    git commit --no-edit

Check it worked

  1. Check nothing is left
    PowerShell
    git diff --check

    Nothing is printed when every marker is gone.

Undo it
  1. Give up and go back
    PowerShell
    git merge --abort

    Cancels the whole merge. Nothing is lost.

New to Merge conflict? I explain it in plain English on Layman Terms.