Git - 使用filter-branch删除空变更集的提交 [英] Git - remove commits with empty changeset using filter-branch

查看:151
本文介绍了Git - 使用filter-branch删除空变更集的提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何使用git filter-branch删除没有变更集的提交?

我使用以下代码重写了我的git历史记录:

  git filter-branch --tree-filter'rm -r -f my_folder'-f HEAD 

这个解决方案效果很好,但现在我有很多提交空变更集的提交。我想删除这些提交。最好在msysgit。



重新分配不是真正的选择,因为我有超过4000个提交,其中一半必须被移除。

解决方案

只需在 - 修剪空白选项上添加:

git filter-branch --tree-filter'rm -rf my_folder'--prune-empty -f HEAD

(当然,如果你有其他的参考资料,你可能想用 - > all 而不是 HEAD 。)



请注意,这与 - 提交过滤;在这种情况下,查尔斯贝利有你的答案


How do I remove commits which have no changeset using git filter-branch?

I rewrote my git history using:

git filter-branch --tree-filter 'rm -r -f my_folder' -f HEAD

this worked out well but now I have lots of commits with empty changesets. I would like to remove those commits. Preferably in msysgit.

Rebasing is not really an option because I have over 4000 commits and half of them must be removed.

解决方案

Just add on the --prune-empty option:

git filter-branch --tree-filter 'rm -rf my_folder' --prune-empty -f HEAD

(And of course, if you have other refs, you might want to rewrite everything with -- --all instead of just HEAD.)

Note that this isn't compatible with --commit-filter; in that case, Charles Bailey has your answer.

这篇关于Git - 使用filter-branch删除空变更集的提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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