Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pushing a git repo fails with error: contains '.git'

Tags:

git

mercurial

I converted a few mercurial repos to git using the hg-fast-export tool and while all of them were converted fine, one produced the following error when I pushed the repo.

$ 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'

"contains '.git'" error has very broad terms and couldn't find any documentation so I tried to search for an existing '.git' folder in the original repo and I did. There was a subsubsub-folder that contains an instance of an old git repository which I removed with git rm, however, the problem remained.

Is there anyway I can push this to github or a new clean repo is the only option?

Any help in this appreciated. Thanks!

like image 812
jimkont Avatar asked Nov 16 '25 21:11

jimkont


1 Answers

You can use the convert command with a filemap to strip the git repo from the repository. After that it will be gone from the history, and the repository will be safe for importing to git.

Example:

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

Note that convert is a bundled extension which you first need to enable in your .hgrc like so:

[extensions]
convert =

For more information see hg help convert.

like image 200
Laurens Holst Avatar answered Nov 19 '25 11:11

Laurens Holst



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!