Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.9k views
in Technique[技术] by (71.8m points)

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

enter image description here

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...