I was trying to push my code to my git but accidentally did a git revert. It looks like this:
[master 36aff31] Revert "Addded files"
54 files changed, 44739 deletions(-)
delete mode 100644 myfolder/.DS_Store
delete mode 100644 myfolder/1198232958151161470_462274348.jpg
delete mode 100644 myfolder/localfile.py
................
................
I did a git checkout .
in order to get files back but nothing happened. How can I get my files back?
If you want to keep your commit history clean while undoing your accidental git revert
, you can use git reset
with the --hard
option to set the state of your working directory back to the commit immediately before the current (revert) commit ( HEAD^
):
git reset --hard HEAD^
NB: be sure that you haven't made any other commits since the accidental commit or this will discard those changes from your working directory.
If you don't care about a clean commit history, running a second git revert
is probably safer.
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.