0

I wanted to push my project in github as usual. but I got this error. what it means, and what I should do?

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

thank you very much in advance.

mojtaba1
  • 53
  • 11
  • `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.` – tkausl Nov 03 '18 at 15:35
  • It tells you in the error what to do. You have changes on the remote that you don’t have locally. Doing a “git pull” should fix it as it says in the message. – Charlie Fish Nov 03 '18 at 15:35
  • thanks a lot . it was very helpful – mojtaba1 Nov 03 '18 at 19:20
  • 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) – phd Nov 05 '18 at 11:13
  • https://stackoverflow.com/search?q=%5Bgit%5D+Updates+were+rejected+because+the+remote+contains+work+that+you+do+not+have+locally – phd Nov 05 '18 at 11:13

1 Answers1

1

The critical portion of the error message is this:

hint: Updates were rejected because the remote contains work that you do hint: not have locally.

The remedy for this problem is probably just doing a pull:

git pull origin master

The problem is that you are asking GitHub to play one or more commits onto a base which has diverged from the base on which you actually made those commits. By pulling first, you are updating your base such that it becomes possible for GitHub to accept your commits.

Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360