我怎样才能找到空的git提交?

Eug*_*ash 7 git git-filter-branch

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

And*_*w C 9

您想要排除无父提交和合并提交,然后查看哪些提交与其父提交的树相同.

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
Run Code Online (Sandbox Code Playgroud)