试图在GitHub上推送更改,但是我收到了错误

时间:2015-03-14 07:35:32

标签: git github version-control

考虑:

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

2 个答案:

答案 0 :(得分:0)

我也有这个问题......输出让我感到惊讶:

git push github master
To git@github.com:Joey-project/project.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com:Joey-project/project.git'

如果我没记错的话,一般方法是使用以下命令的变体:

git fetch github; git merge github/master

查看How to commit after removing a directory from GIT可能会有所帮助,它给了我一个很好的基本想法。

答案 1 :(得分:0)

  

问题原因

您正试图在没有与其同步的情况下推送到远程存储库。所以要么先拉,然后推进它......

执行git pull

然后执行git push

  

解决这个问题很难(直到你不得不这样做)

git push -f

然而,上面的命令将剥离您不同步的内容。换句话说,所有那些你没有的提交都将通过这个命令从repo中删除。

所以不要使用它,直到你必须这样做。

相关问题