Skip to content

Instantly share code, notes, and snippets.

@facelordgists
Created May 13, 2015 05:28
Show Gist options
  • Star 54 You must be signed in to star a gist
  • Fork 15 You must be signed in to fork a gist
  • Save facelordgists/80e868ff5e315878ecd6 to your computer and use it in GitHub Desktop.
Save facelordgists/80e868ff5e315878ecd6 to your computer and use it in GitHub Desktop.
Recursively remove .git folders
( find . -type d -name ".git" && find . -name ".gitignore" && find . -name ".gitmodules" ) | xargs rm -rf
@Shelob9
Copy link

Shelob9 commented Sep 18, 2018

Thanks. I added .gitattributes
`( find . -type d -name ".git" && find . -name ".gitignore" && find . -name ".gitmodules" && find . -name ".gitattributes" ) | xargs rm -rf

@luckman212
Copy link

I see a couple of problems here.

  1. Separating the find commands with && means that the subsequent ones will only run if the last one had an exitcode == 0. That might not always be the case.

  2. Lots of forking (find -> find -> find -> find -> xargs). That could be simplified and done without any pipes:

find . \( -name ".git" -o -name ".gitignore" -o -name ".gitmodules" -o -name ".gitattributes" \) -exec rm -rf -- {} +

@JasinYip
Copy link

Great! Thank you!

@pihamchi
Copy link

smart guys!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment