Git remove directory

hrickards picture hrickards · Dec 22, 2009 · Viewed 60.1k times · Source

I've got a repository on GitHub (http://github.com/hrickards/PHP-Crypto) for a little project me and a couple of others are working on. My development environment is Aptana Studio, and I use the EGit plugin as Aptana is basically Eclipse underneath. Today the designer sent the HTML and CSS for the website with the images in a folder named img. Previously the images were in a folder called images. Thinking nothing of it and being too lazy to update the CSS and HTML, I simply kept the images in the img directory and commited to Git. However, the GitHub web interface shows both the img and images directories, with the images directory being empty. I've tried deleting the images directory with git rm -r images and git rm images, and even mkdir images; git add images; git rm -r images but whatever I try I get the same result: fatal: pathspec 'images' did not match any files.

Has anyone got any advice on how to remove images, or am I misunderstanding Git or something?

Answer

Sk606 picture Sk606 · Apr 7, 2014

This is what I use, and I think you'll want to as well. It's close to the other answers, but instructs git to NOT change the local files.

git rm -r -f --cached DirectoryName
  • -r : recursive
  • -f : force
  • --cached : apply ONLY to index (staging area). Git leaves the local copies alone.