`! [rejected] main -> main (fetch first)` / `(non-fast-forward)`
BeginnerTroubleshootingPush, Pull and Fetch Errors
Answer
Likely causes → The remote branch has commits you do not have locally, so your push would discard them.
Diagnose →
git fetch origin
git log --oneline --graph HEAD origin/main -10
Fix → Integrate first: git pull --rebase (or git merge origin/main), fix conflicts, test, then git push. Do not use --force on a shared branch.
Prevent → Pull before you start work and keep branches short-lived.
More on Push, Pull and Fetch Errors
`remote: error: GH006: Protected branch update failed for refs/heads/main.`Intermediate`! [rejected] feature -> feature (stale info)` with `--force-with-lease`.Intermediate`You are not currently on a branch.` when running `git pull` or `git push`.Beginner`There is no tracking information for the current branch.` when running `git pull`.Beginner`fatal: The current branch feature has no upstream branch.` on `git push`.Beginner`error: Your local changes to the following files would be overwritten by merge:` during `git pull`.Beginner