git push rejected (non-fast-forward)? Pull first, then push

Ship ItChecked against the official source

The short answer

GitHub's docs: sometimes Git can't make your change to a remote repository without losing commits. When this happens, your push is refused. It usually means someone or something else, such as an AI builder's sync, pushed to the same branch first. Fetch and merge the remote changes with yours, or use git pull to do both at once, then push again.

What to do

  1. Run git pull origin YOUR_BRANCH_NAME to fetch and merge the remote changes.
  2. If the same lines changed on both sides, resolve the conflict.
  3. Push again.

Good to know

  • Our tip: don't use git push --force just to make the error go away. It can overwrite the commits that were pushed before yours.

Source

Checked on 8 Nov 2026. Prices, limits and settings change, so check the source before you rely on them.

Related