无法从Git递归删除文件

Léo*_* 준영 32 git rm

我想在〜/ bin /中删除Git中的所有文件.

我跑

git rm -r --cached ~/.vim/*                      # Thanks to Pate in finding --cached!
Run Code Online (Sandbox Code Playgroud)

我明白了

fatal: pathspec '.vim/colors' did not match any files
Run Code Online (Sandbox Code Playgroud)

这个错误消息建议我使用以下PATH,因为〜/ .vim/**不起作用

~/.vim/*        # I get the error
~/.vim/*/*/*    # This removes files from the index at ~/.vim/folderA/folderB/file1.txt
~/.vim/*/*      # similar error as to the first PATH
Run Code Online (Sandbox Code Playgroud)

如何从Git中删除〜/ .vim中的所有文件和子目录?

-

Von*_*onC 37

 git rm -r --cached ~/.vim/*   
 fatal: pathspec '.vim/colors' did not match any files
Run Code Online (Sandbox Code Playgroud)

1 /你不需要' *':

 git rm -r --cached ~/.vim
Run Code Online (Sandbox Code Playgroud)

将处理任何跟踪的子文件.

2/fatal: pathspec '.vim/colors' did not match any files只是意味着你在1 /中列出的命令之前尝试过的一个命令,并且没有更多要删除的文件!

# to test that command, first reinitialize the state of the repository
# save first if you have any other current modifications
$ git reset --hard

# then check the rm works
$ git rm -r --cached ~/.vim
rm '.vim/aPath/aFile1'
rm '.vim/aSecondPath/aFile2'
rm '.vim/aThirdPath/aFile3'

# try it again
$ git rm -r --cached ~/.vim
fatal: pathspec '.vim/colors
Run Code Online (Sandbox Code Playgroud)


小智 10

即使有本地修改,您想要删除它们吗?

git rm -rf bin/*
Run Code Online (Sandbox Code Playgroud)

或者您想从索引中删除但保留文件本身?

git rm -r --cached bin/*
Run Code Online (Sandbox Code Playgroud)

还试试:

git help rm
Run Code Online (Sandbox Code Playgroud)