弱智 AI 在 pre-commit hook 不过的时候总是把我的前一笔提交 –amend 掉来绕过检查,这很坏。
恢复步骤
1
| git checkout -b backup && git checkout -
|
- 在
git reflog 中找到 –amend 提交的上一笔提交,reset 过去
1 2 3 4 5
| > git reflog 3da0ee0 (HEAD -> main, backup) HEAD@{0}: checkout: moving from backup to main 3da0ee0 (HEAD -> main, backup) HEAD@{1}: checkout: moving from main to backup 3da0ee0 (HEAD -> main, backup) HEAD@{2}: commit (amend): refactor: replace async-tungstenite with tokio-tungstenite 1109673 HEAD@{3}: commit (amend): refactor: replace async-tungstenite with tokio-tungstenite
|
1
| git reset --hard 1109673
|
- 接着把带有 –amend 的那笔提交 cherry-pick 过来,此时会有冲突,接受遴选的修改即可
1 2 3
| git cherry-pick 3da0ee0
git cherry-pick --continue
|