2013-02-06 102 views
2

我使用hg-fast-export工具將一些mercurial回購轉換爲git,雖然所有這些轉換都很好,但當我推送回購。推一個git回購失敗,錯誤:contains'.git'

$ git remote add origin [email protected]:asdf/zxcv.git 
$ git push -u origin master 
Counting objects: 7840, done. 
Delta compression using up to 8 threads. 
Compressing objects: 100% (2817/2817), done. 
error: object 324f9ca2aaae7b1d716db3fc31c02d391c1c2c16:contains '.git' 
fatal: Error in object 
error: pack-objects died of signal 13 
error: failed to push some refs to '[email protected]:asdf/zxcv.git' 

「包含」 git的」錯誤具有十分廣闊的條款,但沒有找到任何文件,所以我試圖在原來的回購來搜索現有的「git的」文件夾,我做到了。有一個sububsub文件夾,其中包含我用git rm刪除的舊git存儲庫的實例,但問題依然存在。

無論如何,我可以推這到github或新的清潔回購是唯一的選擇?

在此讚賞任何幫助。 謝謝!

回答

4

您可以使用convert命令和文件圖從存儲庫中去除git repo。之後它將從歷史中消失,並且存儲庫對於導入到git是安全的。

例子:

$ echo "exclude path/to/.git" > my-filemap 
$ hg convert --filemap my-filemap originalrepo newrepo 

注意convert被捆綁擴展,您首先需要確保您的.hgrc像這樣:

[extensions] 
convert = 

欲瞭解更多信息,請參閱hg help convert

0

您試圖推送的變更集包含.git的歷史記錄,即使不是最新的變更集,所以我認爲您需要創建一個乾淨的回購站。

但是,替代方案可能是重新設置一些變更集。提供你想要推送的內容,其中添加了多餘的.git之前的變更集,並且您不介意丟失一些歷史記錄詳細信息,您可以將它們rebase納入一個變更集中並嘗試推送。在理論上(!!).git目錄將被有效地「編輯」出歷史記錄。

下面是一個例子(注意,我不使用git儘可能水銀,所以不知道這是否會工作,或者如果我的命令是有效的,但它可以給你一個起點):

$ git log --oneline 
1234567 More changes 
abcdefa made changes 
a5b6482 Added .git sub-sub-sub-directory to repo! 
dead123 More things 

$ git rm sub-sub-sub/.git 
$ git commit -m "Removed .git sub-sub-sub-directory" 
$ git log --oneline 
beef456 Removed .git sub-sub-sub-directory 
1234567 More changes 
abcdefa made changes 
a5b6482 Added .git sub-sub-sub-directory to repo! 
dead123 More things 

$ git rebase -i HEAD~4 
... at this point you need to interactively specify what to do* 
$ git log --oneline 
eeee987 Some new commit message that sums up the changes 
dead123 More things 

當我嘗試這個時,被壓扁的變更列表出現在編輯器中,這與我見過的所有教程都不同 - 我猜是由於添加和刪除的文件的衝突。我將四個變更集中的三個命令修改爲「壓扁」而不是「挑選」,這會指示rebase-merge將該變更集壓縮到其父項中。我基本上將所有的變更集合壓縮成一個。它似乎適用於我,其餘的變更集都沒有刪除的文件。這是否會讓你推或不推,我不知道。

當然,先嚐試一下這個克隆或其他東西。