可以使用 git rebase 的交互模式来删除特定的commit。基本步骤如下:
1. 找到要删除的commit之前的commit hash
```bash
git log
```
2. 启动交互式rebase
```bash
git rebase -i --committer-date-is-author-date <要删除的commit之前的commit-hash>
```
3. 在打开的编辑器中,找到要删除的commit行,将其前面的`pick`改为`drop`(或直接删除那一行),保存退出
4. 强制推送到远程仓库(如果需要)
```bash
git push --force
```
这个操作会保持其他commit的原始时间戳不变。但需要注意:
- 这会改变commit hash
- 如果涉及到远程仓库,需要强制推送
- 建议在操作前先创建备份分支
- 如果删除的commit与其他commit有依赖关系,可能需要解决冲突

438

被折叠的 条评论
为什么被折叠?



