Skip to content

How would you find all git repository in a directory ? #1323

Closed Answered by tavianator
PierreAntoineGuillaume asked this question in Q&A
Discussion options

You must be logged in to vote

You can use --prune so fd 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:

$ find -name .git -printf '%h\n' -prune
$ # Or, if your find doesn't have -printf
$ find -name .git -prune | sed 's|/.git$||'

Replies: 1 comment 8 replies

Comment options

You must be logged in to vote
8 replies
@PierreAntoineGuillaume
Comment options

@PierreAntoineGuillaume
Comment options

@toshmukhamedov
Comment options

@PierreAntoineGuillaume
Comment options

@PierreAntoineGuillaume
Comment options

Answer selected by PierreAntoineGuillaume
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants