1

I had a folder on github, say folder which I renamed to folder1 a few commits ago. I now see that both folder and folder1 show up in my repository. How can I remove the old folder. I have tried git rm and git mv but they don't work because folder doesn't exist in my directory tree anymore.

yayu
  • 7,758
  • 17
  • 54
  • 86
  • http://stackoverflow.com/questions/6313126/how-to-remove-a-directory-in-my-github-repository – MorKadosh Nov 12 '14 at 08:02
  • Possible duplicate: http://stackoverflow.com/questions/6313126/how-to-remove-a-directory-in-my-github-repository – SBI Nov 12 '14 at 08:02

2 Answers2

5

You should use git mv to rename folders:

git mv <old> <new>

It will rename your folder, remove the old name from your repository, and add the new one. You also can use this bunch of commands:

mv <old> <new>
git add <new>
git rm <old>

If you want to remove a whole directory that has already been pushed, use this:

git rm -r <old>
git commit -m "Remove unused directory"
git push origin master
zessx
  • 68,042
  • 28
  • 135
  • 158
2

You can try this: git rm -rf directory_name

It will force delete the directory.

gpullen
  • 1,093
  • 2
  • 14
  • 28