How do I search for all my git repositories on my Mac? [closed]
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 years ago.
Improve this questionI'm curious where I've scattered my git repositories across my mac. I'm trying to figure out how I could do a search to find them all so I can organize my life a bit. How can I do this?
Find is your friend. a .git folder will exist in each of your repositories so finding the location of them will give you all your repos.
find /Users/username -name ".git" -print
Use find
:
find ~ -name .git
This searches for the .git
directory that is created in all (non-bare) Git repositories.
Choice of a suitable file to search for to find bare repositories is left as an exercise for the reader.
In shell:
find $HOME -type d -name ".git"
Assuming you have locate
, this should be much faster:
locate .git |grep git$
If you have gnu locate or mlocate, this will select only the git dirs:
locate -ber \\.git$
精彩评论