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

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

问题描述

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

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

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

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.

谢谢.

推荐答案

为了从服务器备份裸repo,您​​应该避免直接复制 repositoryname.git 文件夹(包含本地配置,包括 gitlab 钩子),而是做一个 git 包(参见 我对 git 包的回答).

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

这将生成 一个 文件,您可以轻松地复制该文件,并从中克隆,以便在另一台机器上恢复该 repo.

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.

.git/object 文件夹 将在克隆后重新填充正确的对象.

The .git/object folder will be re-populated once cloned, with the right objects.

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

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