Git: how to remove history before a specific commit

前端 未结 3 488
野趣味
野趣味 2021-01-02 05:29

I.e., I have:

root -- c1 -- c2 -- .. - c1000 -- c1001 -- c1002 -- .. -- c2000 -- top

and I want to have:

root = c1000 -- c1         


        
3条回答
  •  醉梦人生
    2021-01-02 06:07

    Easiest way is with a git graft. If you edit the file .git/info/grafts, you can put lines in the file of the format

    [ref] [parent1] [parent2] ...

    Any commits referenced on the left side are then treated as if the parents listed on the right are the parents of that commit. So you can insert a line like

    c1000

    and it will be treated as though it has no parents. This can then be "baked in stone" by running git-filter-branch.

提交回复
热议问题