首页 > 解决方案 > 推入 Git 时显示错误消息

问题描述

当我推入 Git 时,我发现以下错误

![rejected] master -> master (fetch first) error: failed to push some refs to ' https://github.com/smitraDA/DataScienceProject2.git ' 提示:更新被拒绝,因为远程包含你做的工作 提示:不是在当地有。这通常是由另一个存储库推送提示引起的:to the same ref. 您可能希望在再次推送之前先集成远程更改提示:(例如,'git pull ...')。提示:有关详细信息,请参阅“git push --help”中的“关于快进的说明”。

我已经克隆、添加 -A 和提交。如下:

C:\Users\Dell-672206>git clone https://github.com/smitraDA/DataScienceProject2.git 致命:目标路径“DataScienceProject2”已存在且不是空目录。

C:\Users\Dell-672206>cd DataScienceProject2

C:\Users\Dell-672206\DataScienceProject2>git add -A

C:\Users\Dell-672206\DataScienceProject2>git commit -m "version1"

我发现以下错误:

![rejected] master -> master (fetch first) error: failed to push some refs to ' https://github.com/smitraDA/DataScienceProject2.git ' 提示:更新被拒绝,因为远程包含你做的工作 提示:不是在当地有。这通常是由另一个存储库推送提示引起的:to the same ref. 您可能希望在再次推送之前先集成远程更改提示:(例如,'git pull ...')。提示:有关详细信息,请参阅“git push --help”中的“关于快进的说明”。

标签: github

解决方案


在这种情况下,您必须首先从 GitHub 获取数据并将所有更改从 GitHub 拉到本地存储库,然后推送到远程存储库。您可以使用以下命令:

$ git pull origin master
$ git push origin master

推荐阅读