2013-02-06 104 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将该变更集压缩到其父项中。我基本上将所有的变更集合压缩成一个。它似乎适用于我,其余的变更集都没有删除的文件。这是否会让你推或不推,我不知道。

当然,先尝试一下这个克隆或其他东西。