简体   繁体   English

恢复已删除的git存储库

[英]Restoring a removed git repository

I'm new to git and I've made a couple of commits to local repo. 我是git的新手,我已经对当地的回购做了几次承诺。 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). 最后我打算清理我的桌面...我删除了一个完整的目录(repo clone)。 After cloning repo from server there wasn't any of my commits. 从服务器克隆repo后,没有任何提交。

Could you tell me please is it possible to restore removed repo (changes)? 你能告诉我,是否可以恢复已删除的仓库(变更)? I'm using Windows 7 + TortoiseGit. 我正在使用Windows 7 + TortoiseGit。

Thanks in advance. 提前致谢。

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. 下面是底线:如果您没有推送本地仓库中的更改,然后删除该仓库,那么您的更改曾经在源控制系统中的事实无法帮助您。

Response to comment: 回复评论:

I'm not surprised that you have been using SVN (cvs-isch). 你一直在使用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. 在git中,您只在本地提交并使用推/拉机制来同步彼此不同的不同存储库。

The commit in git can be looked as some form of cached commit in SVN, you queue up your changes for a later synchronization. git中的提交可以看作是SVN中某种形式的缓存提交,您可以将更改排队等待以后进行同步。 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. 版本控制不能解决愚蠢问题;)您唯一能做的就是尝试通过雇用可以重建已丢失数据的人来从硬盘驱动器中恢复数据。

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... 版本控制只能做那么多......

就在下次你知道的时候,你可能想要像git reset --hard @{1}这样的东西让你的本地存储库恢复到意外拉动之前的状态。

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

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