How to delete all .git directories in a folder on Linux.
This find command will display all .git directories in the current folder:
find . -type d -name ".git" \ && find . -name ".gitignore" \ && find . -name ".gitmodules"
Print
./.git ./.gitmodules ./foobar/.git ./footbar2/.git ./footbar2/.gitignore
There should be only 3 or 4 .git directories, because git has only one .git folder for each project. You can do it manually.
If you feel that you delete them all in one team and live dangerously:
//Retrieve all the files named ".git" and pump them into 'rm -rf' //WARNING if you don't understand why/how this command works, DO NOT run it! ( find . -type d -name ".git" \ && find . -name ".gitignore" \ && find . -name ".gitmodules" ) | xargs rm -rf //WARNING, if you accidentally pipe a `.` or `/` to xargs rm -rf, //then everything will be gone. Which requires an OS reinstall.
Eric Leschinski Nov 19 '13 at 20:29 2013-11-19 20:29
source share