How to restore files in git?
Suppose I git clone a repository. Then edit a file A and delete a 开发者_开发技巧file B. How can I restore my working copy to the original status?
Something similar to svn up.
git reset --hard HEAD
is the command that will fully reset your working directory to what was in the most recent commit of the current branch. Be careful. All the work in your commit before you do the reset
will be clobbered, and you'll lose it.
If you only need to reset a single file without modifying anything else, git checkout -- fileA.txt
will revert only that file (regardless of whether it has been just edited or fully deleted).
精彩评论