我将如何使用 SubGit 提供的 Git 存储库?
1 回答
按照以下说明将 SubGit 用于 GitLab 管理的存储库:
- 在 GitLab 中创建空的 Git 存储库;
在 GitLab 服务器上,导航到存储库目录:
对于手动安装,路径是/home/git/repositories/<group>/<project.git>
对于 Omnibus 安装,路径是/var/opt/gitlab/git-data/repositories/<group>/<project.git>
为创建的存储库配置 SubGit 镜像:
$ subgit configure --svn-url <url> <project.git>
调整配置文件:指定分支和标签映射等。
$ edit <project.git>/subgit/config
调整作者映射文件:
$ edit <project.git>/subgit/authors.txt
指定要用于 SVN 服务器的凭据:
$ edit <project.git>/subgit/passwd
将 SubGit 安装到 Git 存储库中:
$ subgit install <project.git>
初始导入完成后,转到 GitLab 存储库页面,查看导入的更改是否显示在那里。如果存储库仍然为空,请尝试重新启动 GitLab 实例,因为这应该会刷新内部缓存。
请注意,根据文档,GitLab 7.5+ 保留hooks目录供内部使用,而必须使用custom_hooks目录来自定义pre-receive和post-receive hooks。
subgit install
另一方面,生成hooks/pre-receive和hooks/post-receive可执行脚本,这可能会破坏服务器托管的所有存储库的 GitLab 设置。
因此,如果您要使用 GitLab 7.5+,我建议您遵循这些稍作调整的说明:
1.— 6. 同上步骤;
暂时将hooks目录移动到hooks_backup:
$ mv <project.git>/hooks <project.git>/hooks_backup
将 SubGit 安装到 Git 存储库中:
$ subgit install <project.git>
将生成的hooks目录移动到custom_hooks:
$ mv <project.git>/hooks <project.git>/custom_hooks
最后恢复 GitLab 钩子:
$ mv <project.git>/hooks_backup <project.git>/hooks
之后,GitLab 应该在每次推送时触发 SubGit 挂钩,因此 SubGit 能够将推送的提交与 SVN 存储库同步。