重新设定git历史记录的特定部分

问题描述

是否有可能(通过重新定位)获得此

<lots of commit above>
* 54dda... commit d 
* 78adf... commit c
* 65d3aa0 .. branch commit 3
* 404b9cf .. branch commit 2
* 77e8a38 .. branch commit 1
* e239d7... commit b
* 78azee... commit a
<lots of commit below>

从这里

<lots of commit above>
* 54dda... commit d 
* 78adf... commit c
|\
| * 65d3aa0 .. branch commit 3
| * 404b9cf .. branch commit 2
| * 77e8a38 .. branch commit 1
|/
* e239d7... commit b
* 78azee... commit a
<lots of commit below>

解决方法

类似这样的东西:

git checkout 78adf
git reset --soft 65d3aa0
git commit -m 'commit C'
# same content as 78adf,but it's not a merge anymore.... auhor/committet are you (dates adjusted as well)
# then replay whatever was on top of it
git cherry-pick 78adf..whatever-branch
# if you like the result,set a branch over here
git checkout -b some-branch