Skip to content
CodeKruPro

git push is rejected. What do you do?

QuizEasy-MediumAsked in: Accenture, Capgemini, TCS, Wipro

git push fails with "Updates were rejected because the tip of your current branch is behind its remote counterpart". What is the right next step?

  • Bring in the remote commits first (git pull, with merge or rebase), fix any conflicts (places where both sides changed the same lines), run the tests, then push again
  • git push --force
  • Delete your local repository and clone again
  • Wait a few minutes and retry the same push

This question is part of Pro+

Pro+ opens every question in Interview Prep and the mock interview. Every article and the first 2 questions of each topic stay free. Hands-on Selenium and API tasks follow their course lesson's own lock.

See Pro+

Already have Pro+? Sign in