从外网迁移 Git 仓库到内网环境通常涉及到几个步骤,包括在外网环境中备份仓库。以下是详细步骤:
1. 在外网环境备份 Git 仓库
首先,在外网环境中,您需要创建仓库的完整备份。这可以通过克隆仓库并创建一个裸仓库(bare repository)来实现:
git clone --bare [外网仓库URL] git名称
例如:
git clone --bare http://git.xuxuweizhi.cn/pt/serv.git serv.git
这将创建一个包含整个 Git 历史的裸仓库。
2.创建一个新的裸仓库
-
然后,在新的 Git 服务器上,创建一个新的裸仓库:
git init --bare [内网仓库路径]
例如:
git init --bare http://git.xuxuweizhi.cn/xx/serv.git
-
最后,将解压的仓库内容推送到新创建的内网仓库:
cd old-repository.git git push --mirror [内网仓库路径]
例如:
git push --mirror http://git.xuxuweizhi.cn/xx/serv.git