推送git repo失败并显示错误:包含'.git'

jim*_*ont 3 git mercurial

我使用hg-fast-export工具将一些mercurial repos转换为git,虽然所有这些都转换得很好,但是当我按下repo时会产生以下错误.

$ git remote add origin git@github.com: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 'git@github.com:asdf/zxcv.git'
Run Code Online (Sandbox Code Playgroud)

"包含'.git'"错误有非常广泛的术语,找不到任何文档,因此我尝试在原始仓库中搜索现有的".git"文件夹,我做了.有一个subsubsub文件夹,其中包含我使用git rm删除的旧git存储库的实例,但问题仍然存在.

无论如何我可以把它推到github或新的清洁回购是唯一的选择吗?

任何帮助在此赞赏.谢谢!

Lau*_*lst 5

您可以将该convert命令与filemap一起使用,以从存储库中剥离git repo.之后它将从历史记录中消失,并且存储库可以安全地导入到git.

例:

$ echo "exclude path/to/.git" > my-filemap
$ hg convert --filemap my-filemap originalrepo newrepo
Run Code Online (Sandbox Code Playgroud)

请注意,这convert是您首先需要启用的捆绑扩展,.hgrc因此:

[extensions]
convert =
Run Code Online (Sandbox Code Playgroud)

欲了解更多信息,请参阅hg help convert.