如何安装Gitlab以在Subgit存储库上运行?

Jon*_*age 5 git gitlab subgit

我刚刚开始使用SubGit,并希望结合使用Gitlab.

我如何使用SubGit提供的Git存储库?

vad*_*hev 5

请按照以下说明将 SubGit 用于 GitLab 管理的存储库:

  1. 在 GitLab 中创建空的 Git 存储库;
  2. 在 GitLab 服务器上,导航到存储库目录:

    对于手动安装,路径是/home/git/repositories/<group>/<project.git>

    对于 Omnibus 安装,路径是/var/opt/gitlab/git-data/repositories/<group>/<project.git>

  3. 为创建的存储库配置 SubGit 镜像:

    $ subgit configure --svn-url <url> <project.git>
    
    Run Code Online (Sandbox Code Playgroud)
  4. 调整配置文件:指定分支和标签映射等。

    $ edit <project.git>/subgit/config
    
    Run Code Online (Sandbox Code Playgroud)
  5. 调整作者映射文件:

    $ edit <project.git>/subgit/authors.txt
    
    Run Code Online (Sandbox Code Playgroud)
  6. 指定用于 SVN 服务器的凭据:

    $ edit <project.git>/subgit/passwd
    
    Run Code Online (Sandbox Code Playgroud)
  7. 将 SubGit 安装到 Git 存储库中:

    $ subgit install <project.git>
    
    Run Code Online (Sandbox Code Playgroud)
  8. 初始导入完成后,转到 GitLab 存储库页面并查看导入的更改是否显示在那里。如果存储库仍然为空,请尝试重新启动 GitLab 实例,因为这会刷新内部缓存。

请注意,根据文档,GitLab 7.5+ 保留hooks目录供内部使用,而必须使用custom_hooks目录来代替自定义pre-receivepost-receive hooks。

subgit install另一方面,生成hooks/pre-receivehooks/post-receive可执行脚本,这可能会破坏服务器托管的所有存储库的 GitLab 设置。

因此,如果您打算使用 GitLab 7.5+,我建议您遵循这些稍微调整的说明:

  1.— 6. 同上步骤;

  1. 暂时将hooks目录移动到hooks_backup

    $ mv <project.git>/hooks <project.git>/hooks_backup
    
    Run Code Online (Sandbox Code Playgroud)
  2. 将 SubGit 安装到 Git 存储库中:

    $ subgit install <project.git>
    
    Run Code Online (Sandbox Code Playgroud)
  3. 将生成的钩子目录移动到custom_hooks

    $ mv <project.git>/hooks <project.git>/custom_hooks
    
    Run Code Online (Sandbox Code Playgroud)
  4. 最后恢复 GitLab 钩子:

    $ mv <project.git>/hooks_backup <project.git>/hooks
    
    Run Code Online (Sandbox Code Playgroud)

    之后,GitLab 应该在每次推送时触发 SubGit 挂钩,因此 SubGit 能够将推送的提交与 SVN 存储库同步。