我试图推动我的项目(所有文件在一个新的存储库)。我遵循这些步骤,但当我用git push -u origin master推时,我得到这个错误:

! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com:asantoya/projectnewbies.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again.  See the
'Note about fast-forwards' section of 'git push --help' for details.

我得到这个错误很多次,不知道该怎么做。


当前回答

注意:这绝不是git的推荐用法。这将覆盖远程上的更改。只有在100%确定本地更改应该推送到远程主服务器时才这样做。

⚠️试试这个:git push -f origin master

其他回答

我在github创建了新的回购,我有同样的问题,但它也有问题,而拉,所以这为我工作。

但在已经有很多这样的代码的回购中,不建议这样做 会把一切都搞砸

git push origin master --force

如果有人在尝试推到heroku时出现此错误,则只需将“origin”替换为“heroku” 是这样的: Git push -f heroku master

试试这个命令:"git pull origin master"

这对我很管用。

查看这个链接:https://help.github.com/articles/dealing-with-non-fast-forward-errors

试试这个,对我来说很管用

这是个错误

这是因为您对它的主人进行了相互冲突的更改。你的存储库服务器不能用这些词告诉你,所以它给出了这个错误因为这不是他为你处理这些冲突的问题,所以他让你自己去做。是吗?

1- git拉 这将把您的代码从存储库合并到站点管理员的代码。 所以冲突就显现出来了。

2-处理这些手册冲突。

3-

git push origin master

瞬间,你的问题就解决了。