git 如何备份git服务器?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2870564/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to backup git server?
提问by Hymanson
How to backup git server? When git server is broken, How can I push my local repository to a new git server?
如何备份git服务器?当 git 服务器损坏时,如何将我的本地存储库推送到新的 git 服务器?
回答by VonC
You can use:
您可以使用:
That way:
那样:
- you have only one file to move to a backup server
- you actually can use this file as an "origin" repo from which you can pull/push data like a regular Git repo.
- 您只有一个文件可以移动到备份服务器
- 您实际上可以将此文件用作“原始”存储库,您可以像常规 Git 存储库一样从中拉取/推送数据。
You will for the first backup create a full bundle:
您将为第一次备份创建一个完整的包:
$ git bundle create /tmp/foo-all --all
回答by Michael Mrozek
You back it up like any other server, just mirror the files; git stores its metadata in files like anything else. If you move the repository to a new machine, you need to change your local repository's origin to point to it. In .git/config
you'll find something like:
您像任何其他服务器一样备份它,只需镜像文件;git 像其他任何东西一样将其元数据存储在文件中。如果将存储库移动到新机器上,则需要更改本地存储库的来源以指向它。在.git/config
你会发现类似的东西:
[remote "origin"]
url = SOMETHING
Change SOMETHING
to the address of your new server
更改SOMETHING
为新服务器的地址