无法使用 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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 07:29:37  来源:igfitidea点击:

Cant rm folder with GIT rm?

gitgit-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

  1. $ rm -r images/blue_white/
  2. $ git rm -r images/blue_white/
  3. $ git commit -m 'Remove images/blue_white directory'
  1. $ rm -r images/blue_white/
  2. $ git rm -r images/blue_white/
  3. $ git commit -m 'Remove images/blue_white directory'

回答by jmh

It sounds like you are in the f04directory, not the imagesdirectory.

听起来您在f04目录中,而不是images目录中。

回答by crafter

This works

这有效

git rm -r --cached blue_white 

Then do a commit.

然后做一个提交。

回答by user1564286

I just noticed that git rmdeletes a directory when the last remaining file is removed.

我只是注意到git rm删除最后一个剩余文件时删除一个目录。

With only myFileresiding in myDir, after performing
git rm myDir/myFile
directory myDirwas gone. Note that I didn't use the -roption.

myFile驻留在myDir,执行后
git rm myDir/myFile
目录myDir就不见了。请注意,我没有使用该-r选项。