有没有办法从“repository.git”恢复文件? [英] Is there a way restore files from "repository.git"

查看:533
本文介绍了有没有办法从“repository.git”恢复文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的本地服务器上有一个git服务器。我想从服务器端直接复制repositoryname.git文件夹来备份这些git存储库。

如果新服务器出现问题,是否可以从这些文件夹中恢复文件?我认为这些文件存储在这个.git文件夹的Object文件夹中。而不是直接从服务器访问。



谢谢。

解决方案

为了从服务器备份裸回购,您应避免直接复制 repositoryname.git 文件夹(其中包含本地配置,包括gitlab挂钩),而是要做一个git bundle (请参阅我对git包的回答)。

  cd repositoryname.git 
git包创建/tmp/repositoryname.bundle --all

这将生成一个文件,您可以轻松地复制并克隆它们,以便在另一个文件夹上还原该回购机器。



使用正确的对象克隆后, .git / object 文件夹将被重新填充。


We have a git server on our local server. I want to backup these git repositories from server side directly copying "repositoryname.git" folders.

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. 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).

 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.

这篇关于有没有办法从“repository.git”恢复文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆