Completely remove (old) git commits from history

后端 未结 1 1218
忘掉有多难
忘掉有多难 2020-12-08 14:46

I\'m starting a project using git where I\'ll be committing very large files, but only a few times a week. I\'ve tried to use git as-is and it seems to store the entire file

相关标签:
1条回答
  • 2020-12-08 14:56

    This should be a simple git rebase -i where you have

    p A
    s B
    s C
    p D
    p E
    

    and then edit the commit message for A-C to be just C's commit message.

    git-rebase will "squash" all the commits into a single commit, who's objects are the same as commit C's objects.

    Note: It may be possible to use git filter-branch to change the big files in the previous commits to actually match the new ones, if you'd rather do that. But its a dangerous operation and I don't want to give you a bad command on accident.

    0 讨论(0)
提交回复
热议问题