简体   繁体   中英

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM