CS FundamentalsHardProduct-company MCQ pattern

git push origin main is rejected with a 'non-fast-forward' error. What does it mean, and what is the correct fix on a shared branch?

  1. A. Your local branch is behind on tags; run git push --tags
  2. B. The remote main has commits you do not have; fetch and integrate them (git pull or git pull --rebase), then push again
  3. C. Your commits are too large; split them and push again
  4. D. The remote branch is protected; rename your branch and push

Correct answer: B. The remote main has commits you do not have; fetch and integrate them (git pull or git pull --rebase), then push again

A push is accepted only if it fast-forwards the remote branch. Someone else pushed first, so you must integrate their commits locally and push again. git push --force would overwrite their work and is the wrong fix on a shared branch.

More Software Engineering, Git and Cloud Basics questions

Exams that ask this topic