【发布时间】:2020-10-15 02:05:43
【问题描述】:
我查看了所有内容,但找不到解决我正在尝试做的事情的方法。也许我只是错过了。
说我有:
Commit A:
- file 1
- file 2
- file 3
Commit B:
- file 4
Commit C:
- file 5
- file 6
HEAD: has files 1-6.
有没有办法以交互方式返回到提交 A 以取消提交文件 2 和文件 3,然后重播剩余的提交? 这样我就剩下了
Commit A:
- file 1
Commit B:
- file 4
Commit C:
- file 5
- file 6
HEAD: has files 1-6, with file2 and file3 as unstaged.
我找到了不完整的解决方案:
- git reset --soft <commit A>
- make changes
- git commit
但这让我没有剩余的提交(B,C)。
- git rebase -i HEAD~n
- edit <commit>
- make changes
- git commit --amend
- git rebase --continue
但此处的更改是在该提交时提交的文件之上,我不想撤消文件更改,只需取消提交/取消暂存它们。
- git revert -n <commit>
但这会撤消更改。
- git rebase drop <commit>
但这会丢弃整个提交。
我正在寻找 rebase 的回放/--continue,但是软重置的可编辑性。有没有办法做到这一点?
谢谢
【问题讨论】:
标签: git commit rebase history revert