简体   繁体   English

如何使用 git 回滚我的本地项目文件夹?

[英]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.不幸的是,我的项目文件在使用 cursor 时被错误地按下了,然后我意识到我的项目没有被删除。 i get each files previous version of my git.my project commited only in local git but not in github.com.我得到每个文件以前版本的我的 git.my 项目仅在本地 git 但不在 github.Z4D236D9A2DDA10EC5C 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.我可以在 vs 代码提交中看到我的项目文件(所有我想要的)。我尝试了所有的东西,但我无法获得我的最后一次提交,我无法覆盖,也无法在我的本地文件夹中获取所有已删除的文件。

在此处输入图像描述

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>如果只有文件不见了: git checkout <your local branch>

If this doesn't work, maybe git complains about unsaved changes, try this:如果这不起作用,也许 git 抱怨未保存的更改,试试这个:

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 .如果提交消失了,这将为您提供以前 git 命令的某种历史记录,并带有 SHA1 编号以提交“消失”: git reflog These commits are probably still accessible and you can try to run git checkout on them.这些提交可能仍然可以访问,您可以尝试对它们运行git checkout

My Hash was wrong,i got all deleted and changed source file我的 Hash 错了,我全部删除并更改了源文件

before i tried在我尝试之前

git reflo

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

after (corrected hash )之后(更正 hash )

git reflo

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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