Cant rm folder with GIT rm?

邮差的信 提交于 2020-08-02 06:32:26

问题


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.

I want to remove the "blue_white" folder ...

├── 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

回答1:


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



回答2:


It sounds like you are in the f04 directory, not the images directory.




回答3:


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

With only myFile residing in myDir, after performing
git rm myDir/myFile
directory myDir was gone. Note that I didn't use the -r option.




回答4:


This works

git rm -r --cached blue_white 

Then do a commit.



来源:https://stackoverflow.com/questions/12407899/cant-rm-folder-with-git-rm

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!