恢复已删除的 git 存储库

发布于 2024-11-07 01:52:44 字数 184 浏览 0 评论 0原文

我是 git 新手,我已经对本地存储库做出了一些提交。然后我错误地点击了“拉”而不是“推”。最后我开始清理我的桌面......我删除了整个目录(repo 克隆)。从服务器克隆存储库后,没有任何我的提交。

您能告诉我是否可以恢复已删除的存储库(更改)?我正在使用 Windows 7 + TortoiseGit。

提前致谢。

I'm new to git and I've made a couple of commits to local repo. Then by mistake I clicked 'Pull' instead of 'Push'. In the end I starded to cleaning my desktop... I removed a whole directory (repo clone). After cloning repo from server there wasn't any of my commits.

Could you tell me please is it possible to restore removed repo (changes)? I'm using Windows 7 + TortoiseGit.

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

巾帼英雄 2024-11-14 01:52:44

您正在备份本地计算机吗?如果没有,你什么时候开始?

底线是:如果您在本地存储库中进行了未推送的更改,然后删除了该存储库,那么您的更改曾经存在于源代码控制系统中这一事实对您没有帮助。

Are you backing up your local machine? If not, when will you start?

Here's the bottom line: if you have changes in your local repo that you don't push, and then you delete that repo, the fact that your changes were once in a source control system can't help you.

笑咖 2024-11-14 01:52:44

对评论的回应:

对于您一直在使用 SVN (cvs-isch),我并不感到惊讶。了解提交和提交之间的区别至关重要。在 git 中,您仅在本地提交并使用推/拉机制来同步彼此不同的不同存储库。

git 中的提交可以看作是 SVN 中某种形式的缓存提交,您可以将更改排队以供以后同步。实际同步有延迟。很多工作中的人仍然难以获得差异


原始答案:

版本控制并不能治愈愚蠢;)您唯一能做的就是尝试从硬盘驱动器中恢复数据,方法是雇用可以重建数据的人已经迷失了。

Response to comment:

I'm not surprised that you have been using SVN (cvs-isch). It's essential that you learn the difference between commit and commit. In git you only commit locally and use the push/pull mechanism to synchronize different repositories that have diverged from each other.

The commit in git can be looked as some form of cached commit in SVN, you queue up your changes for a later synchronization. The actual sync is delayed. A lot of people at work still have problems getting the difference


Original answer:

Version control is not a cure for stupidity ;) The only thing you can do is to try and recover data from the hard drive by hiring someone that can reconstruct data that has been lost.

黯然#的苍凉 2024-11-14 01:52:44

您提交到本地存储库,而不是服务器。如果您删除了该存储库,则无法从您未提交的存储库中取回提交。版本控制只能做这么多......

You committed to your local repository, not the server. If you deleted that repository, there's no way to get the commits back from a repository you didn't commit to. Version control can only do so much...

余生一个溪 2024-11-14 01:52:44

让您知道,下次您可能需要像 git reset --hard @{1} 这样的东西来将本地存储库恢复到意外拉取之前的状态。

Just so you know for next time, you probably wanted something like git reset --hard @{1} to put your local repository back to the state it was before the accidental pull.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文