How to Shrink/Cut a Git Repo

后端 未结 2 1843
夕颜
夕颜 2021-01-01 01:17

We have a Git repo with 7 contributing developers with over 2.5 years of history and about 10,000 commits. We use Assembla to push and pull from. When we add new developers

2条回答
  •  天涯浪人
    2021-01-01 01:51

    The best step-by-step instructions can be found on the Git SCM historical blog post "Replace Kicker" or in the Git book's chapter on "Replace".

    The short summary is this:

    • Create a new branch that is at the point where you want to cut, say git branch history hash.
    • Push the history to a new repository.
    • Create a new base using git commit-tree.
    • Rebase your post-history commits onto your new base.
    • Push your new truncated master branch up to the server.
    • People can then use git replace to re-connect the history together.

    The original post explains it much better with pictures.

    When dealing with complex histories involving merges, this may not work well, depending on how well git rebase --onto works with --preserve-merges. You should obviously test well before proceeding.

提交回复
热议问题