git 如何取消整个文件夹的版本?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2938791/
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
How to unversion an entire folder?
提问by nubela
I have a folder versioned in a git. I want to unversion it, that is to remove the .git meta data, how can I do this?
我有一个 git 版本的文件夹。我想对其进行反版本,即删除 .git 元数据,我该怎么做?
Thanks
谢谢
回答by Jeet
If the folder is the top level of a git repository, and you actually want to completely remove the entire git repo associated with the folder, then simply delete the (hidden) .git
directory from the folder:
如果该文件夹是 git 存储库的顶层,并且您实际上想要完全删除与该文件夹关联的整个 git 存储库,则只需.git
从文件夹中删除(隐藏)目录:
cd foldername
rm -r .git
If the folder is a subdirectory of a git repository, then gautier's method is the one you want:
如果文件夹是 git 存储库的子目录,那么 gautier 的方法就是你想要的:
git rm --cached -r foldername/
回答by Gautier Hayoun
If you want to remove the files from git, but keep them in your filesystem add the option --cached.
如果您想从 git 中删除文件,但将它们保留在您的文件系统中,请添加选项 --cached。
git rm --cached -r foldername/
回答by Yuval Adam
git rm -r foldername/
git rm -r foldername/