When a push is rejected
Lesson 19 of 24 · Git.Micro
If someone pushed while you were working, the server refuses your push: accepting it would erase their commits. Integrate their work first.
"rejected (fetch first)" means the server has commits you don't have.
git pull brings them in (with a merge commit if the histories diverged), then git push works.
Never fix it with git push --force: that overwrites the server and deletes your teammates' work.
This sandbox has pull.rebase=false, so git pull merges. git pull --rebase also works and gives a straight history.
Your push was rejected with "fetch first". What's the right move?
You committed Add gallery, but Ana pushed first. Try to push, then integrate her work and publish yours, without losing anything.
The server's main has “Add opening hours”
Do it in the browser: a real Git tool, a short mission and instant feedback. No install.
Start this lesson — free