1

In my git repository I have a small directory structure under the root directory along with a very big directory structure under .git directory. I would like to use the find command to get a list of all directories under $(REPO_DIR) but not including any directory under $(REPO_DIR)/.git (including). I tried something like

find $(REPO_DIR) -type d ! -name ".git"

and

find $(REPO_DIR) -wholename ".git" -prune -type d

But unfortunately none worked as expected, any suggestions?

e271p314
  • 3,841
  • 7
  • 36
  • 61

2 Answers2

2

Try:

 find . -type d -not -iwholename '*.git*'

or:

find . -type d  -not -path './.git*'
Fredrik Pihl
  • 44,604
  • 7
  • 83
  • 130
0

As an alternative, if you're using bash, you could turn on extglob mode.

shopt -s extglob

This would allow you to do (from within $(REPO_DIR)):

find !(.git) -type d

See this answer for full details: https://stackoverflow.com/a/217017/24

Community
  • 1
  • 1
sanmiguel
  • 4,580
  • 1
  • 30
  • 27
  • Sorry, didn't work, it runs from `shell` command in a makefile `VPATH := . $(shell find $(REPO_DIR) -type d -not -wholename "*.git*")` – e271p314 Dec 18 '13 at 13:30
  • Ah, then it definitely won't work for you. Guess the `$(REPO_PATH)` variable format should have clued me in... – sanmiguel Dec 18 '13 at 13:33