5

I have a repository. ("git init")

I've done check-ins and commits and logs and stuff. But, how can I remove all traces of git and delete git off this directory (and subdirectories)?

I'm on Ubuntu.

TIMEX
  • 259,804
  • 351
  • 777
  • 1,080

4 Answers4

16

This worked for me:

find . -name .git -print0 | xargs -0 rm -rf
Peter Lang
  • 54,264
  • 27
  • 148
  • 161
stevekrzysiak
  • 376
  • 3
  • 7
  • 1
    ..and for me, thank you Steve! You can run `git status` afterwards to verify that the directory will not be a git directory afterwards... – gsamaras Sep 21 '16 at 02:06
6

Simply remove the .git directories inside and you're done.

Daniel DiPaolo
  • 55,313
  • 14
  • 116
  • 115
  • 1
    Also look for .gitignore files in subdirectories, which are not part of the repository. – MarkD Jun 24 '11 at 20:30
4

I would wildcard that .git

find . -name "*.git*" -print0 | xargs -0 rm -rf;
Robbie Bardijn
  • 483
  • 2
  • 6
-1

This works well too.

find . | grep .git | xargs rm -rf
Enki
  • 1,565
  • 2
  • 13
  • 20