为什么我无法将我的代码推送到github?

为什么我无法将我的代码推送到github?

问题描述:

$git push origin master 
To [email protected]:dimitar9/first_app.git 
! [rejected]  master -> master (non-fast-forward) 
error: failed to push some refs to '[email protected]:%USERNAME/first_app.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. 
+0

谢谢哈马尔和韦斯,但怎么能忽略所有的远程变化?我只是想强制推送我的本地版本。我可以这样做吗? – 2012-01-08 04:41:36

+2

你不能。远程服务器配置为“仅快进更新”。有两种方法可以解决这个问题。 (a)做Hammar和Wes提出的建议,或者(b)推到新的分支。 – 2012-01-08 04:54:13

+0

其实,你可以,但你不应该:https://help.github.com/articles/dealing-with-non-fast-forward-errors – 2012-08-21 17:37:41

这意味着有在GitHub上有些变化还没有被合并到当前的分支。要解决此问题,请执行以下错误消息:git pull,解决所有冲突,然后再次尝试推送。

你需要做一个git pull第一。

更新与解释:因为你没有最新的代码,混帐迫使你推更改之前做您身边的合并。这是为了防止他人所做的更改失败。

如果您有任何冲突,你应该检讨他们决定在本地或远程代码是否要提交什么。