简体   繁体   English

如何恢复.git文件夹删除?

[英]How to recover .git folder deletion?

I accidentally deleted my.git folder, I would like to recover the.git folder, but I permanently deleted it .我不小心删除了我的.git文件夹,我想恢复.git文件夹,但我永久删除了它

Will I lose all my project's history?我会丢失所有项目的历史记录吗?

I also tryed the following solution with no success.我也尝试了以下解决方案,但没有成功。

Notes :备注

  • It happened when I imported the code to the Eclipse IDE.当我将代码导入 Eclipse IDE 时发生这种情况。
  • I made many local changes without pushing them.我做了很多本地更改而没有推动它们。
  • I also using GitHub as a repo.我还使用 GitHub 作为回购。
  • Using Windows 10.使用 Windows 10.

If you have pushed your changes to GitHub, then all your history is sitting in the repo on GitHub.如果您已将更改推送到 GitHub,那么您的所有历史记录都位于 GitHub 的存储库中。 You can clone the repo again.您可以再次克隆存储库。

If you have not pushed your changes to a remote repo, then the only place that those changes existed is in your local.git directory in your project directory, and those changes are now gone.如果您尚未将更改推送到远程存储库,那么这些更改存在的唯一位置是项目目录中的 local.git 目录,这些更改现在已经消失。

I had to re-clone the repository and paste the.git folder in the recently cloned project, into the project's folder.我不得不重新克隆存储库并将最近克隆的项目中的 .git 文件夹粘贴到项目的文件夹中。

So I only lost the local commits.所以我只丢失了本地提交。

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

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