Git remove history commit

匿名 (未验证) 提交于 2019-12-03 01:00:01

问题:

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?

回答1:

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.

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.



回答2:

Deleting history probably won't fix your problem. Chances are, at some point in time, a large file was committed to the repository and subsequently removed.

I would take a look at Find files in git repo over x megabytes, that don't exist in HEAD.



转载请标明出处:Git remove history commit
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!