取消初始化 git 存储库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22540577/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 17:53:54  来源:igfitidea点击:

Uninitialize git repository

git

提问by u2908528

I have Initialized a git repository and have made some commit in that now for some reason I do not want to track any files in it and want to remove git from my local repo. Is there some way I can Uninitialize it?

我已经初始化了一个 git 存储库,并且出于某种原因现在已经在其中进行了一些提交,我不想跟踪其中的任何文件并想从我的本地存储库中删除 git。有什么方法可以取消初始化它吗?

回答by Chris Maes

git stores all the repository related data in a folder named ".git" inside your repository folder. So you just want to keep your files but change it into a "not-git-repository". Warning: this is irreversible!

git 将所有与存储库相关的数据存储在存储库文件夹内名为“.git”的文件夹中。所以您只想保留您的文件,但将其更改为“not-git-repository”。警告:这是不可逆的!

cd path/to/repo
rm -rf .git

The only files that might remain are hidden ".gitignore" files (but only if you added them yourself or using some tool like eclipse). To remove them:

唯一可能保留的文件是隐藏的“.gitignore”文件(但前提是您自己添加了它们或使用了诸如 eclipse 之类的工具)。要删除它们:

find . -name ".gitignore" | xargs rm

回答by WeylynCadwell

Just deleting the .gitdirectory stored in the repository will pretty much do it.

只需删除.git存储在存储库中的目录即可。