推送回购失败 (Git/GitHub)

Push to repo failed (Git/GitHub)

我正在尝试将我的文件推送到 GitHub 上的存储库,但收到错误消息。谁能帮我解释一下我做错了什么?

正在抛出一条错误消息,但我无法理解它(我是 Git 的新手...)

git push -u origin master

> To https://github.com/URL  ! [rejected]        master -> master (fetch
> first) error: failed to push some refs to 'https://URL' 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.

如有任何帮助,我们将不胜感激。

发生这种情况是因为您在服务器上进行了在本地没有的更改。

关注下方

  1. 从远程拉取 git pull origin master
  2. 推送到远程。 git push origin master

这通常发生在有人在你拉取之后推送到远程分支。因此,您的提交历史变得不同于服务器提交历史。在这种情况下,如果 git 允许您推送,则服务器上的提交历史(真实来源)将被更改,并且从回购中获取 pull 的人也会面临冲突。因此,您的推送被拒绝了。

但是,如果您非常确定这是一个新的存储库并且没有人对主遥控器进行任何更改(如下面的评论所述)运行 此 git 推送 - f 起源大师