30

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
  • 15,816
  • 22
  • 71
  • 119

3 Answers3

40

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
  • 36,750
  • 6
  • 48
  • 52
23

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,892
  • 22
  • 17
1

git rm -r foldername/

Yuval Adam
  • 155,852
  • 90
  • 298
  • 388