git - Looking for folders containing bare git repositories
问题描述
If they were working copy of git repositories, we could start simply with the approach of looking for every folder with the name ".git" (find . -type d -name ".git"
), as answered here.
But in big storages, how to detect all folders containing bare git repositories?
解决方案
我使用以下代码:
locate -b \*.git |
while read path; do
if [ -f "$path" ]; then
echo "$path is a gitlink file (perhaps in a submodule)"
elif [ -d "$path" ]; then
if [ "`basename \"$path\"`" = .git ]; then
echo "$path is repository"
else
echo "$path is bare repo"
fi
fi
done
警告 1:要使用locate
,您需要将系统配置为updatedb
定期运行(通常每晚从cron
)
警告 2:代码假设您所有的裸存储库都命名为name.git
. 我的是。
推荐阅读
- javascript - 如何传递一个 URL 的 JSON 响应并将其传递到另一个 JSON URL 以获取结果?
- java - Settings.xml 没有从命令行获取我的 java8 配置文件
- java - 删除没有 JPA 映射的 1:1 父表单子实体
- c# - 处理同时连接两次数据库
- python - Python新手,我该如何循环?
- image-processing - 将 PCA 应用于 CNN 的图像时,我必须给它灰度图像吗?
- python - 如何在 scipy 差分进化中传递/访问目标函数内部使用的变量
- quarkus - Quarkus - 忽略 @Path("/") 的资源,而是从资源中加载内容
- amazon-web-services - 是什么导致带有 waithandle.url 的 cfn-signal 出现 403 错误
- c++ - 在 C++ 中具有明确定义的分配器的危险指针