繁体   English   中英

快速从git存储库中删除所有文件

[英]Quickly remove all files from a git repository

在存储库中,我有很多不必要的文件,我想从存储库中删除这些文件,仅将其保存在本地。 我了解这是通过以下方式完成的:

git rm --cached a_file

...或使用-r (如果它是文件夹)。

现在,删除所有内容并添加一些我需要的文件变得更加容易。 如果我使用* ,当给定的文件不在仓库中,而是在相同的本地文件夹中时,git会正确地抱怨。

我应该如何进行?

编辑:使用-f标志将不起作用:

$ git rm --cached -fr *
fatal: pathspec 'somefile' did not match any files

git rm--ignore-unmatch标志完全--ignore-unmatch我的要求。

$ git rm --cached bla
fatal: pathspec 'bla' did not match any files
$ git rm --cached --ignore-unmatch bla
$

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM