gpt4 book ai didi

git - 撤消未提交文件的 git checkout 覆盖

转载 作者:太空狗 更新时间:2023-10-29 14:23:38 24 4
gpt4 key购买 nike

我曾使用命令 git checkout -- $(git ls-files -m) 撤消某些文件上的 git rm。但是,我修改了一些其他文件而没有提交它们,这些文件已经恢复到它们之前的提交,丢失了未提交的更改。

有没有办法恢复这些更改?
我想不会用 git,因为更改没有添加到 git。如果有帮助,在 Mac 上。

谢谢汤姆

最佳答案

"Does git checkout really silently overwrite uncommitted changes?"
And the answer is still "yes" in 2018 (just tested with 2.11)

2019 年 8 月 Git 2.23 确实如此,只是现在多了一个 explicit git restore command

一个简单的 git restore . 也会从索引内容静默恢复工作树(所以如果文件被修改但没有添加到所述索引,它们的更改仍然会丢失)

但至少有 no confusion possible between checkout of files and of branch .

关于git - 撤消未提交文件的 git checkout 覆盖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22959549/

24 4 0