Bash 如何打印git repo中每个子文件夹的最新提交时间?

Bash 如何打印git repo中每个子文件夹的最新提交时间?,bash,git,shell,Bash,Git,Shell,我知道我可以使用git log和相当的日志格式%ci来获取任何文件的最后提交时间。 git log -1 --pretty="format:%ci" /path/to/repo/anyfile.any -1将其限制为文件最后一次更改 我遇到的问题是,我想清除大型git回购上的长期非维护子文件夹。 根据上次提交时间,我可以确定应该清除哪个文件夹。 此外,是否存在打印文件夹深度仅限于1级的情况 find /path/to/repo -maxdepth 1 -type d \!

我知道我可以使用
git log
和相当的日志格式
%ci
来获取任何文件的最后提交时间。

git log -1 --pretty="format:%ci" /path/to/repo/anyfile.any
-1将其限制为文件最后一次更改

我遇到的问题是,我想清除大型git回购上的长期非维护子文件夹。
根据上次提交时间,我可以确定应该清除哪个文件夹。

此外,是否存在打印文件夹深度仅限于1级的情况

find /path/to/repo -maxdepth 1 -type d \! -name .git
使用命令列出最大深度为1的所有对象,只过滤目录(
-type d
)并排除目录
.git
\!
表示“不”)


使用但不列出
中的目录,而不列出文件系统中的目录。

您可以使用
查找
-exec
选项,向git询问每个找到的目录的最后一次提交:

find -maxdepth 1 -type d -not -name .git -exec git log -n1 --format=format:"%ci {}" -- \{} \;

缺少右括号,以修复“不匹配的括号”。find-maxdepth 1-type d-not-name.git-exec git log-n1--format=format:“%ci{}”---\{};
find -maxdepth 1 -type d -not -name .git -exec git log -n1 --format=format:"%ci {}" -- \{} \;