Git basics

Fix "you have divergent branches" when you pull

Your copy and GitHub both have new commits. Tell Git to put yours on top of theirs.

  1. Pull and put your commits on top
    Terminal
    git pull --rebase

    Stopped with a conflict? Fix the files, run git add on them, then git rebase --continue.

  2. Push
    Terminal
    git push
  3. Make this the default from now on
    Terminal
    git config --global pull.rebase true

    Then plain git pull won't ask again.

Check it worked

  1. Check you're in step
    Terminal
    git status
Undo it
  1. Stop the rebase if it goes wrong
    Terminal
    git rebase --abort
  1. Pull and put your commits on top
    Terminal · Ubuntu / Debian
    git pull --rebase

    Stopped with a conflict? Fix the files, run git add on them, then git rebase --continue.

  2. Push
    Terminal · Ubuntu / Debian
    git push
  3. Make this the default from now on
    Terminal · Ubuntu / Debian
    git config --global pull.rebase true

    Then plain git pull won't ask again.

Check it worked

  1. Check you're in step
    Terminal · Ubuntu / Debian
    git status
Undo it
  1. Stop the rebase if it goes wrong
    Terminal · Ubuntu / Debian
    git rebase --abort
  1. Pull and put your commits on top
    PowerShell
    git pull --rebase

    Stopped with a conflict? Fix the files, run git add on them, then git rebase --continue.

  2. Push
    PowerShell
    git push
  3. Make this the default from now on
    PowerShell
    git config --global pull.rebase true

    Then plain git pull won't ask again.

Check it worked

  1. Check you're in step
    PowerShell
    git status
Undo it
  1. Stop the rebase if it goes wrong
    PowerShell
    git rebase --abort