我怎样才能找到空的git提交? [英] How can I find empty git commits?

查看:135
本文介绍了我怎样才能找到空的git提交?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用哪些命令在git存储库中查找空提交,即将被 git filter-branch --prune-empty 删除的提交。 ?

What command(s) can I use to find empty commits in a git repository, i.e. the commits that would be removed by git filter-branch --prune-empty?

推荐答案

您希望排除无父级提交和合并提交,然后查看哪些树与父级具有相同的树。

You'd want to exclude parentless commits and merge commits, then see which ones have the same tree as their parent.

for sha in $(git rev-list --min-parents=1 --max-parents=1 --all)
do
   if [ $(git rev-parse ${sha}^{tree}) == $(git rev-parse ${sha}^1^{tree} ) ]
   then
       echo "${sha} will be pruned"
   fi
done

这篇关于我怎样才能找到空的git提交?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆