我一直在尝试将我的工作推送到 github 上,但出现此错误:
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.
答案 0 :(得分:1)
首先尝试 git pull
,然后尝试推送。
如果上面不起作用,那么试试这个,
git push --force-with-lease origin
(这将覆盖本地分支的远程更改。)
错误是因为你的 origin 分支在你的 local 分支之前。
答案 1 :(得分:1)
您应该在将来自远程源的更改与本地更改合并之前执行 git pull
。
答案 2 :(得分:0)
试试
$ git pull --rebase origin master
$ git push -u origin master