Git删除历史提交 [英] Git remove history commit

查看:132
本文介绍了Git删除历史提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个超过3年的大型仓库git,我想删除一年多以前的更改历史记录。这可能吗?可以使用git rebase但是如何?

I have a large repository git over 3 years, I want to delete history of changes that were more than a year ago. Is this possible? Can use git rebase but how?

推荐答案

调查称为 git replace ://git-scm.com/2010/03/17/replace.htmlrel =nofollow>本文来自 Pro Git 书,它使用您的确切环境作为其例。基本上,如果你可以在历史中找到一个你想作为新根的点,那么你可以用一个没有父母的提交来替代它,就好像它是在空气中创建的一样。您甚至可以将原始树存储在一台机器上,如果您再次需要它可以轻松恢复历史记录。

Investigate the black magic called git replace in this article from the Pro Git book that uses your exact circumstances as its example. Basically, if you can find a point in history that you want to act as the new root, you can replace it with a commit that has no parents, as if it were created out of thin air. You can even store the original tree on a single machine, making it easy to restore the history if you need it again.

请注意 git rebase (和 git replace ,对于这个问题)是你想重写整个树,包括分支,所以它们都指向到不同的承诺。这也会导致你团队中的其他人难以合并他们的变化,因为所有的父母都有不同的SHA。

Do note that a problem with git rebase (and git replace, for that matter) is that you want to rewrite the entire tree, including branches, so they all point to different commits. This also has the consequence of making it hard for others on your team to merge in their changes, because all of the parents have different SHAs than they had before.

这篇关于Git删除历史提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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