一不小心删除了一个文件怎么办?如果不小心删除一个文件,应该看到这样的提示:
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
deleted: app/Theme.php
此时直接git checkcout是不行的,应该先git reset HEAD app/Theme.php。注意看提示其实已经说了。
测试你再一次git status:
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: app/Http/Controllers/Controller.php
deleted: app/Theme.php
modified: readme.md
modified: resources/views/show_partials/item_themes.blade.php
modified: resources/views/wlddy/show.blade.php
modified: resources/views/wlddy/wlddyform.blade.php
modified: resources/views/wlj/wljform.blade.php
修改已经到了not staged的分组了。这个时候,你再git checkout App\theme.php就可以了!