开发者

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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜