无法使用 GIT rm rm 文件夹?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12407899/
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
Cant rm folder with GIT rm?
提问by rsturim
I want to remove an entire directory with GIT ... each time I keep getting the same error and don't understand why this is happening.
我想用 GIT 删除整个目录......每次我不断收到相同的错误并且不明白为什么会发生这种情况。
I want to remove the "blue_white" folder ...
我想删除“blue_white”文件夹...
├── css
│?? ├── design.css
│?? └── red_white.css
├── images
│?? ├── blue_white
│?? │?? ├── accordion-button.png
│?? │?? ├── accordion-shadow.png
│?? │?? ├── button1.png
│?? │?? ├── oem-slide-shadow.png
│?? │?? └── truncate-arrow.png
│?? └── red_white
│?? ├── accordion-shadow.png
└── pages.xml
When I do this ...
当我这样做...
git rm -r blue_white/
I get this ...
我明白了这个...
fatal: pathspec 'f04/blue_white/' did not match any files
回答by Nick Kugaevsky
$ rm -r images/blue_white/
$ git rm -r images/blue_white/
$ git commit -m 'Remove images/blue_white directory'
$ rm -r images/blue_white/
$ git rm -r images/blue_white/
$ git commit -m 'Remove images/blue_white directory'
回答by jmh
It sounds like you are in the f04
directory, not the images
directory.
听起来您在f04
目录中,而不是images
目录中。
回答by crafter
This works
这有效
git rm -r --cached blue_white
Then do a commit.
然后做一个提交。
回答by user1564286
I just noticed that git rm
deletes a directory when the last remaining file is removed.
我只是注意到git rm
删除最后一个剩余文件时删除一个目录。
With only myFile
residing in myDir
, after performinggit rm myDir/myFile
directory myDir
was gone. Note that I didn't use the -r
option.
只myFile
驻留在myDir
,执行后git rm myDir/myFile
目录myDir
就不见了。请注意,我没有使用该-r
选项。