SteelReed

Search

Search posts, questions…

DevOps & CloudQuestion 3 / 35

Junior

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.

non-fast-forwardprotected branchhook declined403, Large filespush rejectedWhat does it say?pull --rebase, test, pushPush own branch, open PRRead the remote: linesFix access / use Git LFS

3 points to say:

  1. Non-fast-forward: the remote moved on; pull --rebase (or fetch + merge), rerun tests, then push.
  2. Use --force-with-lease only on your own branch after a rebase; never --force a shared branch.
  3. 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.