简体   繁体   English

通过rsync迁移git存储库

[英]migrating a git repository via rsync

A while ago we setup a git repository for internal use on a local server. 不久前,我们在本地服务器上设置了一个git存储库供内部使用。 The server is not on a business line and thus has a non-static ip. 该服务器不在业务线上,因此具有非静态IP。

We want to move the git origin from the local server to a new remote server (this is our private dedicated server, not github or similar). 我们想将git的来源从本地服务器移动到新的远程服务器(这是我们的专用服务器,不是github或类似服务器)。

Can we just rsync the entire git directory over to the new server? 我们可以将整个git目录同步到新服务器吗?

尽管最简单的方法肯定是执行git clone ,但是可以使用rsync。

The safest way (which would not bring with it local config or hooks, which can be specific to the local environment, and have sensitive information you wouldn't always want to include in an archive) would be to use git bundle. 最安全的方法( 不会随本地配置或钩子一起提供,它可能特定于本地环境,并且具有您不总是希望包含在存档中的敏感信息)将是使用git bundle。

git bundle create /tmp/myrepo.bundle --all

See " How can I email someone a git repository? " 请参阅“ 如何向某人通过git存储库发送电子邮件?

That creates only one file (easy to copy around), which you can clone or fetch from: 这样只会创建一个文件(易于复制),您可以从中克隆或获取该文件:
On the target server 在目标服务器上

git clone myrepo.bundle
cd myrepo

Git repositories have nothing linking them to their directory or server (unless you configured something specifically). Git存储库没有将它们链接到其目录或服务器的任何内容(除非您进行了专门配置)。 You can move them like any other directory of files. 您可以像其他文件目录一样移动它们。 A USB stick, scp, rsync, mv, zip, tar... whatever. USB记忆棒,scp,rsync,mv,zip,tar ...等等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM