Restore deleted file not staged in git

后端 未结 4 614
没有蜡笔的小新
没有蜡笔的小新 2021-01-11 15:57

I accidentally removed the entire directory of my source code...with a nice rm -r. I know, really bad; but fortunately, I had a git repo in the containing directory. Thus, g

4条回答
  •  既然无缘
    2021-01-11 16:08

    git won't have stored any changes that were never added or committed. The best you can do is git checkout that deleted directory, and you'll get it back in the state it was in when things were last committed.

    git checkout

    The local uncommitted changes you are seeing is probably the uncommitted deletion, i.e. git sees that you've deleted a bunch of files, but you haven't committed the fact that they are deleted yet, so git says 'hey, there are some changes (in this case, deletions) you haven't committed.'

提交回复
热议问题