Find All .git in a Directory
To find all the git repositories in a directory, you can run the following command (which search for the
find . -type d -name .git
It is using the
find command, with the type directory, and name
If you want to delete them, you can do this:
find . -type d -name .git | xargs rm -rf
find command has a
-delete option, but that somehow doesn’t work with directory.
Remove all .DS_Store and .gitignore
If you are like me who wants to clean up a directory with all the git stuff and send to a possibly Windows user, you could run these:
find . -name '*.DS_Store' -type f -delete find . -name '.gitignore' -type f -delete
-delete option works for the files.