从Git存储库中的历史记录中修剪空合并提交 [英] Prune empty merge commits from history in Git repository

查看:72
本文介绍了从Git存储库中的历史记录中修剪空合并提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经清理了很多Git存储库,我们需要从历史记录中删除大部分内容.我这样做是:

I have cleaned up our Git repository quite a bit, we need to remove big parts from the history. I do this using:

git filter-branch --prune-empty --tree-filter 'rm -rf some_stuff'

--prune-empty标志将删除在该过程之后留为空白的提交,但具有多个父项的提交(合并提交)除外.即使要合并的分支绝对不包含任何内容,并且合并也不会向树中添加任何内容.

The --prune-empty flag will remove commits that are left empty after the process, except commits with multiple parents (merge commits). Even if the branch being merged in contains absolutely nothing, and the merge adds nothing to the tree.

如何从历史记录中删除这些空的合并提交?

How do I also prune these empty merge commits from the history?

推荐答案

我在这里的filter-branch周围找到了一个非常可爱的小包装脚本:

I found a very cute little wrapper script around filter-branch here:

https://github.com/pflanze/chj-bin/blob/master/cj-git-filter-branch

前提条件和背景:

http://lists.q42.co. uk/pipermail/git-announce/2011-September/000486.html

这篇关于从Git存储库中的历史记录中修剪空合并提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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