简体   繁体   English

有没有办法从“repository.git”恢复文件

[英]Is there a way restore files from “repository.git”

We have a git server on our local server. 我们的本地服务器上有一个git服务器。 I want to backup these git repositories from server side directly copying "repositoryname.git" folders. 我想从服务器端直接复制“repositoryname.git”文件夹备份这些git存储库。

In case of a problem with a new server is it possible to recover files from these folder? 如果新服务器出现问题,是否可以从这些文件夹中恢复文件? I think the files stored as fractured on an Object folder on this .git folders. 我认为这些.git文件夹上的Object文件夹中存储的文件是破碎的。 And not directly accessible from server. 而且无法直接从服务器访问。

Thank you. 谢谢。

In order to backup bare repo from the server, you should avoid copying directly the repositoryname.git folder (which contains local config, including gitlab hooks), but rather do a git bundle (see my answer on git bundle ). 为了从服务器备份裸repositoryname.git ,你应该避免直接复制repositoryname.git文件夹(它包含本地配置,包括gitlab hooks),而是做一个git包(参见我对git bundle的回答 )。

 cd repositoryname.git
 git bundle create /tmp/repositoryname.bundle --all

That will generate one file, that you can easily copy around, and from which you can clone in order to restore that repo on another machine. 这将生成一个文件,您可以轻松复制,并从中可以克隆,以便在另一台计算机上恢复该存储库。

The .git/object folder will be re-populated once cloned, with the right objects. 一旦克隆,将使用正确的对象重新填充.git/object文件夹

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

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