Removing '.git' directory from git repo?

后端 未结 5 1972
名媛妹妹
名媛妹妹 2020-12-09 16:06

I\'m trying to migrate a git repo from Kiln to Github. I can add the new remote just fine, but when I try to push master to the new remote, I get the following error:

<
5条回答
  •  天涯浪人
    2020-12-09 17:01

    Another way to handle the case where a Mercurial (Hg) repo has a .git folder embedded in it is to first "fix" the Hg repo before exporting to Git. @laurens-holst has a great way of doing this.

    If the .git folder was in the root of your project, then your create a text file, my-filemap that looks like:

    exclude ".git"
    

    Enable the Convert extension in your .hgrc file:

    [extensions]
    convert =
    

    Then filter out the .git folder using the Hg convert extension:

    hg convert --filemap my-filemap originalrepo newrepo
    

    Now you can export from newrepo and won't have the issue of the embedded .git folder.

    You can also use git fsck to make sure the new Git repo is ok before pushing it.

提交回复
热议问题