是因为提交文件过大导致内存溢出。
解决方法:
假设您的提交历史如下:
Apply to .gitignore
abcd123 当前提交
efgh456 包含node_modules的提交
ijkl789 较早的正常提交
您可以:
- 回退到添加node_modules之前的提交:
bash
Apply to .gitignore
Run
git reset --soft ijkl789
这会保留所有代码修改,但撤销提交记录
重新提交代码变更(确保node_modules已在.gitignore中):
bash
Apply to .gitignore
Run
git add .
git commit -m "重新提交(不含node_modules)"