31

I have a folder versioned in a git. I want to unversion it, that is to remove the .git meta data, how can I do this?

Thanks

nubela
  • 1
  • 24
  • 75
  • 123

3 Answers3

43

If the folder is the top level of a git repository, and you actually want to completely remove the entire git repo associated with the folder, then simply delete the (hidden) .git directory from the folder:

cd foldername
rm -r .git 

If the folder is a subdirectory of a git repository, then gautier's method is the one you want:

git rm --cached -r foldername/
Jeet
  • 38,594
  • 7
  • 49
  • 56
24

If you want to remove the files from git, but keep them in your filesystem add the option --cached.

git rm --cached -r foldername/
Gautier Hayoun
  • 2,922
  • 24
  • 17
1

git rm -r foldername/

Yuval Adam
  • 161,610
  • 92
  • 305
  • 395