How to change the SHA-1 of a specific commit in place with git?

前端 未结 3 1978
小鲜肉
小鲜肉 2021-01-25 20:36

The target commit may have parents and descendants.

it needs to replace the old commit in place,

so it\'s not as simple as cherry c

3条回答
  •  温柔的废话
    2021-01-25 21:05

    Okay, let's see if this helps.

    WARNING:

    • This break (some) pull / push / fetch.
    • Not all git command support this.
    • It does not share with other users.
    • This does not change the commit, it replace it.

    Are you sure you want to do this? Scroll down if yes.


    This is called graft point. You create a file .git/info/grafts and have the following info:

     
    

    Let's say you have this:

    /---D
    A---B---C
    

    Now you want to replace B with D (without changing the commit id), you put this in graft:

     
    

    It keeps the old commitid, with the limitation stated above.

提交回复
热议问题