2012-01-20 58 views
0

我用以下方法了一會兒:混帳合併停止工作

git fetch origin master 
git merge origin/master 
git push --dry-run origin master 
git push origin master 

現在,這已停止工作,併產生這個錯誤

To [email protected]:company/project/admin.git 
! [rejected]  master -> master (non-fast-forward) 
error: failed to push some refs to '[email protected]: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拉的作品,而不是獲取和合並。

爲什麼會發生這種情況?其他開發人員也會遇到這種情況。

回答

1

我覺得這裏的問題是,你正在做的:

git fetch origin master 

...這將更新FETCH_HEADmasterorigin,但更新遠程跟蹤分支origin/master

你可能想要做的:

git fetch origin 

...相反,這將更新來自origin所有遠程跟蹤分支,包括origin/master

這是在git fetch的文檔中解釋的,但我認爲這很公平地說,這是很多人的困惑......