22. Push asks the remote to move its note
Push sends your commits and asks the remote to fast-forward its branch; it refuses if the remote's tip is not in your history; force skips the check and strands the skipped commits.

22. Push asks the remote to move its note

Push sends your commits and asks the remote to fast-forward its branch; it refuses if the remote's tip is not in your history; force skips the check and strands the skipped commits.

"Rejected, non-fast-forward" is the most common push error and this is the whole explanation.

git push sends your new commits to the remote. Then it asks: move your main to this commit.

Git says yes only if their main is in the history of your commit. A fast forward.

If someone pushed first, their commit is not in your history. The push is refused.

Fetch, then merge or rebase their work in, then push again. Now their commit is behind yours.

A force push skips the check and moves the note anyway. The commits it skipped over lose their note. Use it only on branches that are yours alone.

Check yourself. Why does the remote refuse a push?

Do you like what you are reading? Subscribe to receive updates.

Unsubscribe anytime

Comments