How would you find all git repository in a directory ? #1323
-
I have a find $WORKSPACE -type d -exec test -e '{}/.git' ';' -print -prune how would I replicate that with On a side note, what I did is better that the
But I don't know if I can improve the performance by telling |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 8 replies
-
You can use $ fd -u '^\.git$' --prune -X printf '%s\n' '{//}' That doesn't prune everything but I suspect it's hard to beat in practice. You might also find that this GNU find command line is much faster than using $ find -name .git -printf '%h\n' -prune
$ # Or, if your find doesn't have -printf
$ find -name .git -prune | sed 's|/.git$||' |
Beta Was this translation helpful? Give feedback.
You can use
--prune
sofd
doesn't recurse inside the.git
directories themselves:$ fd -u '^\.git$' --prune -X printf '%s\n' '{//}'
That doesn't prune everything but I suspect it's hard to beat in practice. You might also find that this GNU find command line is much faster than using
-exec test
: