Removing '.git' directory from git repo?

后端 未结 5 1970
名媛妹妹
名媛妹妹 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条回答
  •  Happy的楠姐
    2020-12-09 17:03

    Use the BFG Repo-Cleaner, a simpler, faster alternative to git-filter-branch specifically designed for removing files from Git history.

    Carefully follow the steps here: https://rtyley.github.io/bfg-repo-cleaner/#usage - but the core bit is just this: download the BFG jar (requires Java 8 or above) and run this command:

    $ java -jar bfg.jar --delete-folders .git --delete-files .git --no-blob-protection my-repo.git
    

    Your entire repository history will be scanned, and any file or folder named .git will be removed. I've tested this against a specially-constructed test repo containing a .git folder, and it worked just fine.

    Thanks to Michel Jouvin for reminding me that files named '.git' are also illegal in Git (and the error message reported by Git doesn't make it immediately obvious that they are files, rather than folders), I've updated this answer to reflect that.

    Full disclosure: I'm the author of the BFG Repo-Cleaner.

提交回复
热议问题