Last Updated: February 25, 2016
·
1.976K
· montanaflynn

Recursively delete .git directories

Here's a quick PSA: You probably don’t want to send all the git metadata in a project over the wire every time you deploy to production. That stuff really adds up, especially if you're using npm, composer or another package manager but most importantly any proprietary source code can be retained through git history.

So here's a one liner that will get rid of any .git directories from the current directory down.

find . | grep .git | xargs rm -rf

It's an old tip from my blog but one that's damn important for many developers.