Reputation: 102875
Is it even possible to remove a particular changeset from a Git repository altogether. I want to do this because there was a commit while ago that added some binary files that are absolutely useless for source code management.
I can understand if this is impossible to do given the fact that the commit nodes have parents and a specific history, but I guess it will not hurt to ask.
And the answer is no for questions that ask "can you just clone new copy of the time before that commit occurred and start from there again?".
Upvotes: 8
Views: 5423
Reputation: 28971
Use git rebase -i <commit-id>
, where id is a commit before the changeset you want to remove. It will open a list of commits between the head and the changeset, delete from the list the commit you want and continue. When this commit will be "detached", it means it will be floating in the repository until it's garbage collected. You could use git gc
to force it.
However, you should remember, that all clones of the repository will be diverged, and should be rebased too after it.
Upvotes: 11