我有20个提交,我需要删除其中一个提交(提交#20)。我尝试过:
git reset --hard hashID
但是它正在将头部移动到特定的头部:
HEAD is now at someID
我不想改变头,我只想删除那些改变。
我该怎么办?如何删除特定的提交并保留其余提交?
答案 0 :(得分:1)
如果您不介意重写分支的历史记录:
git checkout hashID~1 # stand on the previous revision
git cherry-pick hashID..the-branch # replay all revisions after the one I want to remove
# if you like the results
git branch -f the-branch