删除提交但保留更改
假设我有这样的提交历史记录:
commit 1 - The first commit
commit 2 - The commit I want to revert, but keep the changes of
commit 3 - The third commit
commit 4 - The fourth commit
[uncommited work]
如果我还没有推送任何东西(或者直到提交1),我如何删除提交2,但是将提交2中所做的更改应用于当前未提交的作品?
我所能找到的只是关于如何删除提交,并将其更改或重置为该提交,这将会(据我所知)从历史记录中删除所有提交。
我会按照你想要的方式重新排序修订版,然后选择提交2,隐藏弹出窗口,然后将HEAD指针设置为“重建”提交4:
git stash save "will come back"
git checkout commit1
git cherry-pick commit2..commit4
git cherry-pick commit2
git stash pop
git reset --soft HEAD~1
应该这样做
我相信git rebase -i HEAD~3
应该能够做到这一点。
然后,您可以选择提交2来编辑,更改提交的内容或已更改的文件,然后git将在编辑的提交2的顶部“重放”提交3和4
链接地址: http://www.djcxy.com/p/49811.html