我正在尝试推送我的项目(新存储库中的所有文件)。我遵循了这些步骤,但是当我使用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.
我收到这个错误很多次了,不知道该怎么办。
发布于 2012-07-28 06:25:28
正如错误消息所说:在尝试git push
之前先执行git pull
。显然,您的本地分支与您的跟踪分支不同步。
根据项目规则和您的工作流程,您可能还希望使用git pull --rebase
。
发布于 2013-12-14 07:52:46
我刚刚收到这个错误。
在创建本地git存储库之后,我创建了一个github存储库,因此在推送到github之前,我需要将更改接受到本地。在这种情况下,唯一的更改是在创建github存储库时作为可选步骤创建的自述文件。
git pull https://github.com/*username*/*repository*.git master
仓库URL位于github项目页面:
然后我重新初始化(这可能不需要)
git init
git add .
git commit -m "update"
然后推送:
git push
发布于 2016-09-16 23:12:25
使用以下命令:
git pull --allow-unrelated-histories <nick name of repository> <branch name>
像这样:
git pull --allow-unrelated-histories origin master
当项目没有任何公共祖先时,就会发生此错误。
https://stackoverflow.com/questions/11696295
复制相似问题