简体   繁体   中英

how to rollback my local project folder using git?

my project files unfortunately deleted while using cursor wrongly pressed then i realised my project not deleted. i get each files previous version of my git.my project commited only in local git but not in github.com. i can see my project files in vs code commits(all what i want).i tried all the things but i cannot get my last commit and i cannot overwrite and cannot get all deleted files in my local folder.

在此处输入图像描述

the above image show where my files stored in my last commit i want every deleted files and overwrite all the changed files.

i tried but not work for me

git reflo

git reset --hard 9a0ffad

Did you delete files, or commits?

If only the files are gone: git checkout <your local branch>

If this doesn't work, maybe git complains about unsaved changes, try this:

git checkout -f <your local branch>

or

git reset --hard

If commit disappeared, this gives you some kind of history of your previous git commands, with SHA1 number to commit that "disappeared": git reflog . These commits are probably still accessible and you can try to run git checkout on them.

My Hash was wrong,i got all deleted and changed source file

before i tried

git reflo

git reset --hard 9a0ffad<------this hash was wrong 

after (corrected hash )

git reflo

git reset --hard 5e0ffad<------after i changed correct hash

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