如何恢复“git rm -r。”? [英] How to revert a "git rm -r ."?
问题描述
我认为
我没有提交。
我认为所有文件都标记为删除并且也从我的本地结帐中删除。
编辑:我可以(如果我知道该命令)恢复到上次提交。但是如果我可以撤销 git rm -r。
,那将会好很多。因为我不确定在最后一次提交之后和 git rm -r。
之前做了什么。
git reset HEAD
应该这样做。如果您没有任何您关心的未提交的更改,那么
git reset --hard HEAD
应强行将所有内容重置为最后一次提交。如果确实有未提交的更改,但第一条命令不起作用,请使用 git存储
保存未提交的更改:
git stash
git reset --hard HEAD
git stash pop
I accidentely said git rm -r .
. How do I recover from this?
I did not commit.
I think all files were marked for deletion and were also physically removed from my local checkout.
EDIT: I could (if I knew the command) revert to the last commit. But it would be a lot better if I could just undo the git rm -r .
. Because I am not really sure what I did after the last commit and before the git rm -r .
.
git reset HEAD
Should do it. If you don't have any uncommitted changes that you care about, then
git reset --hard HEAD
should forcibly reset everything to your last commit. If you do have uncommitted changes, but the first command doesn't work, then save your uncommitted changes with git stash
:
git stash
git reset --hard HEAD
git stash pop
这篇关于如何恢复“git rm -r。”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!