paweb
paweb

Reputation: 141

Git remove history commit

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?

Upvotes: 6

Views: 2907

Answers (2)

Jeff Bowman
Jeff Bowman

Reputation: 95634

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.

Upvotes: 3

addiedx44
addiedx44

Reputation: 2743

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.

Upvotes: 0

Related Questions