-1

I am trying to push to a repo that some merged in changes not in my local.

error: failed to push some refs to 'git@git.corp.myrepo'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing

I remember using in the past a way to pull using rebase to resolve this easily where it would pull and also merge your commits.
What is the best way to resolve this?

sal3jfc
  • 517
  • 4
  • 14
  • This topic should be covered in any Git tutorial, and has been asked many times here. Please run through a Git tutorial, and Google the error message. – joanis Feb 07 '22 at 17:19
  • Does this answer your question? [Updates were rejected because the remote contains work that you do not have locally](https://stackoverflow.com/questions/24357108/updates-were-rejected-because-the-remote-contains-work-that-you-do-not-have-loca) – joanis Feb 07 '22 at 17:20

1 Answers1

1

It looks like someone push new commits to the remote repository after you cloned it


to solve the issue you need to pull the commits made by others by using git pull , and then solve any conflicts if they appear, and only then you can push your changes to the remote repository

another way is to force the push by git push -f , but this is not recommended as it will throw conflict for others

Hamza AZIZ
  • 2,582
  • 1
  • 9
  • 18