简体   繁体   English

在Git的安装目录中误删除了.git文件夹

[英]Accidentally deleted .git folder in Git's install directory

I forgot to $ cd prior to deleting a .git directory and I happened to be inside Git's main folder, located on my hard drive at /usr/local/git . 在删除.git目录之前,我忘记了$ cd ,而我恰好位于Git的主文件夹中,该主文件夹位于我的硬盘驱动器上的/usr/local/git

  • I used $ rm -rf .git 我用$ rm -rf .git
  • I don't have this backed up with Time Machine, but I do have a three-week old clone. 我没有使用Time Machine对此进行备份,但是我有一个三周大的克隆。
  • This is not a tracked repository, just the folder that Git itself's files are in. 这不是一个跟踪的存储库, 只是 Git本身文件所在的文件夹。

I figured there's no need for a .git folder in this directory. 我认为此目录中不需要.git文件夹。 However, just to be safe, I did a $ sudo git init so the folder would be there if Git was looking for it. 但是,为了安全起见,我进行了$ sudo git init因此如果Git正在寻找该文件夹,则该文件夹将存在。

Did I bork anything? 我有什么东西吗? Does Git even use this folder? Git甚至使用此文件夹吗? Should I restore from the old clone instead? 我应该从旧克隆中还原吗?

Thanks! 谢谢!

Update - On re-reading the question, I realize you are not talking about a repository that you had intentionally created. 更新 -重新阅读问题后,我意识到您不是在谈论您故意创建的存储库。 The question doesn't seem to make sense. 这个问题似乎没有道理。 If there was .git at /usr/local/git , it might have been created accidentally while cloning or init of some repo etc. But then you say you had a 3 week old clone of it, which doesn't make sense. 如果/usr/local/git有.git,则可能是在克隆或初始化某些回购等时意外创建的。但是然后您说您有一个3周大的克隆,这没有任何意义。 Anyway, if it is the former case, you need not worry. 无论如何,如果是前一种情况,则不必担心。 There shouldn't have been a .git there and git doesn't make use of it. 那里不应该有.git,而git不使用它。


Does Git even use this folder - this is all that Git uses, because it is your repo. Does Git even use this folder这是Git使用的所有Does Git even use this folder ,因为它是您的存储库。 Unless you have clones of your repo elsewhere or have backed up your repo, you have lost your changes. 除非您在其他位置有您的存储库的克隆或备份了存储库,否则您将丢失所做的更改。 Your 3 week old clone will let you recover some stuff, but any history that you had since then will be lost. 3周大的克隆版本可让您恢复一些东西,但是此后的所有历史记录都将丢失。 Assuming you did not delete your working directory, you can still have your changes, but the history will be lost ( including any branches you had created in the 3 weeks etc.) 假设您没有删除工作目录,您仍然可以进行更改,但是历史记录将丢失(包括您在3周内创建的所有分支等)。

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

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