Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I find all files in a directory recursively, except those in the .git directory?

I tried the folowing: find . \! -name ".*" but that didn't work.

share|improve this question
up vote 2 down vote accepted


find . -name '.git' -prune -o -print

-prune as an action will cause the matched directories to be "pruned" from the search tree, i.e. they won't be searched.

share|improve this answer
Thank you. Also for the explanation. – scrrr Feb 27 '12 at 18:42
-o is the POSIX-compliant of -or (the logical or). So basically, find is looking for something named .git, but prune it, or anything else, and then print it. -print is the default expression that is normally omitted from typical find calls. @scrrr – slhck Feb 27 '12 at 18:45
@slhck: Didn't know that. Thanks! – scrrr Feb 27 '12 at 18:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.