问题
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