git 如何revert指定范围内的commit并且只生成一个新的commit?
答:一共分成两步
一. revert多个commit并生成多个新的commit
git revert <old commit>^..<new commit>
二. 使用rebase将多个新的commit合并成一个commit
git rebase -i <base commit>
举例:
$git log
111111111 yes
222222222 no
333333333 yes or no
4444444444 no or yes
第一步: 执行git revert -n 333333333^..111111111将会生成一个commit,并且commit log将会变成如下状态:
777777777 Revert "yes or no"
666666666 Revert "no"
555555555 Revert "yes"
111111111 yes
222222222 no
333333333 yes or no
4444444444 no or yes
第二步: 执行git rebase -i 111111111