2014-04-04 19 views
4

當混帳TFS無法創建合併提交,它說 warning: this changeset 7504 is a merge changeset. But it can't have been managed accordingly because one of the parent changeset 7494 is not present in the repository! If you want to do it, fetch the branch containing this changeset before retrying...當混帳TFS無法創建合併提交,如何糾正它

按照該documentationNote: if you see a warning, you could correct that by reseting the tfs remote to a previous commit. Then fetch the merged branch and retry to fetch the branch.

任何人都可以請詳細說明reseting the tfs remote to a previous commit。雖然,我現在已經提取了合併的分支,我不明白如何將它重置爲之前提交給失敗的分支。我不確定,但是我必須git checkout <hash of the previous commit>

回答

2

是的,現在git-tfs嘗試創建合併提交,當它遇到合併變更集(現在它有一個令人滿意的分支支持)。

此消息只是一個警告信息,當你看到它,你有2個選項...

  • 第一個是因爲你知道什麼都不做,這是爲爲例,老功能分支,你永遠不會工作,更重要的是,在將來你永遠不會再合併到你的父分支。

  • 第二個是如果你真的想要這個合併提交。因爲你需要一個好的歷史或更重要的,因爲你仍然在這個分支上工作,並且必須將它合併到父分支中。

要做到這一點,你必須遠程重置您的TFS(因爲事實上提交已創建--to跟上以前的版本如何混帳TFS的作品,併爲那些兼容性,可以不與分支機構合作)。

要重置您的遠程,您必須使用reset-remote命令。

然後intitialized合併在父分支與branch --init分支。

重置本地分支到tfs remote(由於內部git-tfs優化)。

並再次獲取父分支。現在,合併後的分支存在,並在取,混帳TFS會發現從合併分支父變更,你將有一個美麗的合併提交您的git倉庫;)

所以,如果你這樣做早些時候

git tfs clone https://CompanyName.visualstudio.com/DefaultCollection "$/CompanyName/Main" KfGitMain --workspace="C:\TFS\Main" 
cd GitMain 
git tfs branch --init "$/CompanyName/Release/20140121.1" live20140121.1 
git tfs branch --init "$/CompanyName/Release/20140121.1-hotfix" hotfix20140121.1 

,如果你收到警告的所有三個由於代碼合併,並從對方,所以你將不得不

git checkout hotfix 
git tfs reset-remote 5fb83335b8dfc6fbb96e0a54a48dc06c506e3277 ## previous commit of the first failed commit 
git reset --hard tfs/hotfix 
git tfs pull -i hotfix 

git checkout live 
git tfs reset-remote eba62a1446f3f81676d051336ca254fe54c37d74 
git reset --hard tfs/live 
git tfs pull -i live 

git checkout master 
git tfs reset-remote 72727737ec52f9b96d22d343770186a342c8b166 
git reset --hard tfs/default 
git tfs pull -i default 

注意:如果你沒有太多的分支機構和/或奇怪的tfs歷史,所有這些都可以使用來避免10與選項--with-branches,將啓動並獲取所有分支照顧合併變更集

+0

我已經添加了我使用的命令根據我的理解你的答案。如有任何錯誤請糾正。 – IsmailS

+0

這很好。只是更新以保存一個命令(使用拉取代fetch + reset),並添加了一個不告訴使用'git clone --with-branches'來避免這種情況... – Philippe

+0

如果你有v0.19.2,你可以在所有git-tfs命令中使用選項'-I'而不是'-i nameOfMyRemote',它將選擇好的遠程使用.... – Philippe