git合并已停止工作

git合并已停止工作,git,Git,我使用以下程序有一段时间: git fetch origin master git merge origin/master git push --dry-run origin master git push origin master 现在,它已停止工作并产生此错误 To git@example.com:company/project/admin.git ! [rejected] master -> master (non-fast-forward) erro

我使用以下程序有一段时间:

git fetch origin master  
git merge origin/master  
git push --dry-run origin master  
git push origin master
现在,它已停止工作并产生此错误

To git@example.com:company/project/admin.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'git@example.com:company/project/admin.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 pull工作,而不是获取和合并


为什么会发生这种情况?这也发生在其他开发人员身上。

我认为这里的问题在于您正在做:

git fetch origin master
。。。它使用
origin
中的
master
更新
FETCH\u HEAD
,但不更新远程跟踪分支
origin/master

您可能想做:

git fetch origin
。。。相反,它将从
原点
更新所有远程跟踪分支,包括
原点/master

这在git fetch的文档中有解释,但我认为公平地说,这让很多人感到困惑