Undo Git mistakes

Fix "rejected: non-fast-forward" when you push

GitHub has commits you don't have yet. Pull them in first, then push.

  1. Get the new commits and put yours 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

Check it worked

  1. Check you're in step with GitHub
    Terminal
    git status
Undo it
  1. Stop the rebase if it goes wrong
    Terminal
    git rebase --abort
  1. Get the new commits and put yours 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

Check it worked

  1. Check you're in step with GitHub
    Terminal · Ubuntu / Debian
    git status
Undo it
  1. Stop the rebase if it goes wrong
    Terminal · Ubuntu / Debian
    git rebase --abort
  1. Get the new commits and put yours 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

Check it worked

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