0

I have been trying to push my work on github but I get this error :

PS C:\Users\xxx\Desktop\wiki\wiki> git push origin --all
To https://github.com/me50/xxx.git
 ! [rejected]        web50/projects/2020/x/wiki -> web50/projects/2020/x/wiki (fetch first)
error: failed to push some refs to 'https://github.com/me50/xxx.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.
Salam-16
  • 21
  • 1
  • 6
  • You should do a git pull because there are new commits on the origin. –  Jun 27 '21 at 15:39
  • https://stackoverflow.com/search?q=%5Bgit%5D+hint%3A+Updates+were+rejected+because+the+remote+contains+work+that+you+do – phd Jun 27 '21 at 19:07

3 Answers3

1

First try git pull and then try to push.

If above doesn't work then try this,

git push --force-with-lease origin (This will overwrite your remote changes by your local branch.)

The error caused because your origin branch is ahead of your local branch.

Dashrath Mundkar
  • 7,956
  • 2
  • 28
  • 42
1

You should do a git pull before to merge the changes from the origin remote with your local changes.

  • yes thanks, I did, then I had to ` git pull origin master --allow-unrelated-histories ` because The error is resolved by toggling the allow-unrelated-histories switch. – Salam-16 Jun 27 '21 at 16:30
0

Try

$ git pull --rebase origin master
$ git push -u origin master

Ref: https://www.programmersought.com/article/22301895864/

buddemat
  • 4,552
  • 14
  • 29
  • 49
HRola
  • 1
  • 1