Your push to the remote is rejected. How do you handle it?
Short answer
Read the error first: the most common case is the remote has commits you don't (non-fast-forward), fixed with git pull --rebase, run tests, push again. Other causes: protected branch, server hook, permissions, file too large.
3 points to say:
- Non-fast-forward: the remote moved on;
pull --rebase(or fetch + merge), rerun tests, then push. - Use
--force-with-leaseonly on your own branch after a rebase; never--forcea shared branch. - A bad commit on a shared branch:
git revert, don't rewrite history.
Keep reading the deep dive
Create a free account to read the full explanation and follow-up questions, mark questions as studied and review them on a schedule.