无法在 git 上推送工作“未能推送一些参考”

时间:2021-06-27 15:35:45

标签: git

我一直在尝试将我的工作推送到 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.

3 个答案:

答案 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

参考:https://www.programmersought.com/article/22301895864/