2011-02-08 148 views
1

我想一個git rebase - 導致衝突 - 爲什麼?

git rebase --onto master myremote/master~21 myremote/master 

從遠程倉庫添加對礦井最新的21個提交。

什麼git告訴我的是有衝突 - 但那可能怎麼樣?

根據我的理解,這只是將21承諾並將其應用於我的主人之上。怎麼會有衝突?

感謝您的幫助!

我在做那個順便說一句,因爲不知何故,我搞砸了我的git-svn倉庫(遠程),並且有21個提交,我沒有管理提交顛覆。所以我試着用一個新的git-svn克隆,我在其中添加了這21個提交。

回答

0

有衝突,如果:

  • 主有承諾不在myremote/master
  • 這些提交包含通用文件/更改與最後一個提交21 myremote/master

如果莫名其妙新鮮git-svn clone有不同的SHA1比以前的git - svn的回購協議,那麼就沒有接近共同祖先,而衝突的機會要高得多。
有關rebase期間衝突的說明,請參閱「How to identify conflicting commits by hash during git rebase?」。重置您的本地主人myremote


單程/主人將是:

git checkout -b tmp myremote/master # local tmp branch from myremote/master HEAD. 
git merge -s ours master    # ignore completely master content 
git checkout master 
git merge tmp      # fast-forward to tmp HEAD 

如果您還沒有獲取myremote/master前作了當地master任何更改,這應該工作。

+0

我不明白。爲什麼要提交主要的問題? rebase只是將當前分支(這裏是myremote/master)重置爲(這裏是master)。所以一切都應該應用在主人的頭上,對吧? – Andy

+0

換句話說:沒有一種方法可以簡單地應用這21個提交,而不需要對共同的祖先和廢話進行git檢查嗎? – Andy

+0

@Andy:對於rebase期間的衝突,請參閱http://stackoverflow.com/questions/2118364/how-to-identify-conflicting-commits-by-hash-during-git-rebase。你的情況的問題是:'master/HEAD'的SHA1(在任何rebase之前)是否與'myremote/master_22'相同?如果不是這樣,共同的祖先進一步落後於「主人」的歷史,因此所有這些衝突。 – VonC