首页 > 解决方案 > 删除 git 中的某些提交

问题描述

你能建议我如何恢复到早期的良好承诺。下面是我的提交代码

git log --oneline
as4c704 (HEAD -> mybranch, origin/master, origin/HEAD, master) Merge branch 'branchA' of repo_name into master
e325c09 (origin/branchA) message
4549e4c Merge branch 'branchB' of repo_name into master
2f32d73 (origin/branchB) Merge remote-tracking branch 'origin/master' into branchB
221e689 Merge branch 'branchC' of repo name into master
f33c1c (origin/branchC) Merge remote-tracking branch 'origin/master' into branchC
6782c19 Merge branch 'branchD' of repo_name into master
1d3s525 Merge branch 'branchE' of repo_name into master
16438a DbranchE
112a682 message
dd3d883 BranchF message
5122492 BranchF message
bg3e17 message
33f71c message
346d27 message
... more

我如何保留提交 346d27、33f71c 和 221e689 并从 33f71c 开始将其删除

标签: git

解决方案


您必须发出命令git rebase -i 33f71c并编辑要删除的每个提交输入drop命令。

然后保存、退出并发出命令git push --force


推荐阅读