这是我所做的:
git status
显示我的所有更改。 git add -A
git commit -m "Foo"
.使用 husky
触发预提交 git 钩子(Hook)和 lint-staged
. git commit -m "Foo"
再次并立即取消。 git status
很干净,git log
和 git reflog
不显示新的提交。 为什么我的更改被还原了?我该如何恢复它们?
最佳答案
好的,它是 lint-staged
惹的祸。它 stash 了我的更改。
所以运行git stash apply
恢复他们!
⚠ 不要尝试运行 lint-staged
的多个实例在同一个 git repo 上并行(例如在 monorepo 中的每个项目上)。这将破坏您的更改,而无法恢复它们。
如果你在 monorepo 上工作,要么按顺序 lint 项目,要么放弃 lint-staged
并检查整个代码库,包括未暂存的文件。
关于git - 为什么在取消 git 提交后我的更改消失了,我该如何恢复它们?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60334337/