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

做~自己de王妃 提交于 2019-12-18 06:59:46

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/17528809/is-there-a-way-restore-files-from-repository-git

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!