将git rm转换为git rm --cached [英] Convert git rm to git rm --cached
问题描述
我正在清理Git仓库中的二进制文件,并使用 git rm
删除了一长串文件。
考虑到更改的规模(7000+文件),我现在认为使用 git rm --cached 代替。
这些文件处于暂存状态,我如何将它们放在磁盘上,同时保持它们不在git中?
我正在寻找一个git命令来做到这一点,我想避免一些讨厌的脚本破解,我的 git co </ code>然后
git rm - 缓存
每个文件。一旦我检查出来,我就不知道我需要再次删除哪些内容,并且必须重做我的工作。这是一个特定子目录的长列表,并不是rm -r *的简单例子。 解决方案
可以通过 git checkout HEAD〜1 - 。
从历史提交中检索文件,您可以用路径替换。
(s)你想检索。
I'm cleaning up binary files in a Git repo and I have a long list of files I removed with git rm
.
Given the scale of the change (7000+ files) I'm now thinking it's more prudent to have used git rm --cached
instead.
The files are in staging, how do I put them back on disk while keeping them out of git ?
I'm looking for a git command to do this, I'd like to avoid some nasty script hack where I git co
then git rm --cached
each file. Once I check them out I won't know which ones I need to delete again and I'd have to redo my work. It's a long list of specific subdirectories, not a straightforward case of rm -r *
Just commit your staged deletions and then you could retrieve files from historical commit by git checkout HEAD~1 -- .
, where you could replace .
with a path(s) you want to retrieve.
这篇关于将git rm转换为git rm --cached的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!