如何在 Mac 上搜索所有 git 存储库?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4319290/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 04:47:42  来源:igfitidea点击:

How do I search for all my git repositories on my Mac?

gitmacos

提问by Josiah

I'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?

我很好奇我把我的 git 存储库分散在我的 mac 上的什么地方。我试图弄清楚如何进行搜索以找到所有这些,以便我可以稍微组织一下我的生活。我怎样才能做到这一点?

回答by Daniel Rucci

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.

查找是您的朋友。您的每个存储库中都将存在一个 .git 文件夹,因此找到它们的位置将为您提供所有存储库。

find /Users/username -name ".git" -print

回答by Greg Hewgill

Use find:

使用find

find ~ -name .git

This searches for the .gitdirectory that is created in all (non-bare) Git repositories.

这将搜索.git在所有(非裸)Git 存储库中创建的目录。

Choice of a suitable file to search for to find bare repositories is left as an exercise for the reader.

选择合适的文件来搜索以找到裸存储库作为练习留给读者。

回答by Wesley Rice

In shell:

在外壳中:

find $HOME -type d -name ".git"

回答by Tobu

Assuming you have locate, this should be much faster:

假设你有locate,这应该快得多:

locate .git |grep git$

If you have gnu locate or mlocate, this will select only the git dirs:

如果你有 gnu locate 或 mlocate,这将只选择 git 目录:

locate -ber \.git$