0

I am getting this error whenever I try to push my project to github:

error: failed to push some refs to 'https://github.com/projectlink.git' hint: Updates were rejected because the remote contains work that you do not have locally. This is usually caused by another repository pushing to the same ref. You may want to first integrate the remote changes (e.g., 'git pull ...') before pushing again. See the 'Note about fast-forwards' in 'git push --help' for details.

I also tried to pull it and then push the code but I still get the same error. Please help!

kowsky
  • 12,647
  • 2
  • 28
  • 41
D Gop
  • 1
  • 3
    Possible duplicate of [How to avoid repetitive message \`Updates were rejected because the remote contains work that you do...\`?](https://stackoverflow.com/questions/49175460/how-to-avoid-repetitive-message-updates-were-rejected-because-the-remote-contai) – bk2204 May 24 '19 at 00:09
  • 1
    Possible duplicate of [git: updates were rejected because the remote contains work that you do not have locally](https://stackoverflow.com/questions/24357108/git-updates-were-rejected-because-the-remote-contains-work-that-you-do-not-have) – kowsky May 24 '19 at 05:44
  • If you've pulled and then pushed and still get the same error them you've pulled a wrong branch, not the one you pushed. Please show you branches and commands that led to the error. – phd May 24 '19 at 09:54

1 Answers1

0

This could happen when

  • Your branch was updated by another dev, so you first have to pull and merge your working copy, then push another commit

  • You have rebased your branch, in this case all commits are re-written so you have to force-push your branch

  • You have amended your commit that was pushed before. Also in this case the history has changed and you have to force-push.

Anyway with the info you gave use it is very hard to help you, we need some context.

Leonardo Rossi
  • 2,922
  • 2
  • 20
  • 28