【问题标题】:How to import an existing bare git repository into Gitlab?如何将现有的裸 git 存储库导入 Gitlab?
【发布时间】:2013-08-13 16:26:45
【问题描述】:

我按照here 的描述将我的裸 git 存储库导入 Gitlab,因为它未被识别为 git 存储库,但创建了一个 94K 大的“空”存储库(原始为 2.8GB 大):

$ bundle exec rake gitlab:import:repos RAILS_ENV=production
fatal: Not a git repository (or any of the parent directories): .git
Processing test.git
INFO: Sidekiq client using redis://localhost:6379 with options:namespace=>"resque:gitlab"}
 * Created test (test.git)
Done!

作为一种解决方法,我将空项目文件夹(由导入试用创建)替换为我的裸仓库。之后我从远程克隆 repo 并得到以下错误:

$ git clone git@mydomain.com:...test.git
Cloning into 'test'
fatal: '...test.git' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

但是 git 用户应该拥有所有需要的权限。 -也许我忽略了什么?

我的系统:RHEL6.3、Git 1.8.3.4、Gitlab5.3。

Gitlab 是否需要一个普通的仓库(非裸仓库)?或者我的问题可能是什么?

【问题讨论】:

    标签: git import repository gitlab


    【解决方案1】:

    Gitlab 是否需要一个普通的仓库(非裸)?

    不,所有由 gitlab 管理的 repos 都是裸 repos。

    你应该看到:

    /home/git/repositories/user1/repo1.git
    /home/git/repositories/user1/repo2.git
    /home/git/repositories/greoup1/repo3.git
    ...
    

    确保您的test.git 文件夹(以及其中的裸仓库文件)的权限与/home/git/repositories/ 下现有的裸仓库相同。

    如果导入不起作用,那么“用我的裸仓库替换空项目文件夹(由导入试用创建)”应该。

    但是:您需要确保将 GitLab(在 ~git/repositories/arepo.git/hooks 中)创建的空裸仓库中的任何钩子复制到完整的裸仓库中,替换空仓库(相同的路径)。
    还要检查 ~git/repositories/arepo.git/info~git/repositories/arepo.git/config 中的内容

    要调试,首先尝试克隆 GitLab 在导入失败期间创建的空裸仓库。
    然后用你自己的替换它,仔细检查钩子并重试。


    作为OPmentioned 并记录在GitLab“Trouble Shooting Guide”中,正确的ssh url 是:

    git@git.myserver.com:repositories/mygroup/proj1.git
    

    提到了:repositories


    导入裸仓库(如Sytse Sijbrandij belowraketasks/import.md 所述)

    • 将你的裸仓库复制到 git repos_path 下(参见config/gitlab.ymlgitlab_shell -> repos_path
    • 运行下面的命令

      bundle exec rake gitlab:import:repos RAILS_ENV=production
      

    【讨论】:

    • 我已将我的导入错误添加到我的问题中,因为我认为主要问题是我的裸仓库的导入。我检查了几次的权限是(drwxrws---。)。
    • 我认为没有创建任何挂钩:***repos 中的 post-receive 挂钩是链接:... Gitlab / test ... 存储库为空***。卫星也是如此。当我尝试通过 ssh 从远程克隆空仓库时,问题也没有消失。但在服务器上克隆工作正常。
    【解决方案2】:

    【讨论】:

    • 好链接。 +1。我已将其包含在我选择的答案中以提高知名度。
    • 您还需要考虑:github.com/gitlabhq/gitlabhq/pull/8140:仅将您要导入的存储库放在命名空间(用户或组子目录)下。
    • 我按照链接页面上的说明进行操作,但没有看到我的新项目。经调查,这是因为该项目是内部项目,没有管理员权限的用户看不到该项目。修复可见性修复了问题。
    【解决方案3】:

    对我来说,复制存储库的位置是 - /var/opt/gitlab/git-data/repositories

    我在上面的目录中复制了我现有的裸存储库并运行 >gitlab-rake gitlab:import:repos 它工作了!!!

    【讨论】:

    【解决方案4】:

    我有!这是我的 ssh 路径中缺少的目录。这个问题已经被here跟踪了。

    抱歉,错误信息不是很明显。我希望这可以帮助像我这样的其他 Gitlab 初学者:)

    猜你喜欢
    • 2021-12-04
    • 1970-01-01
    • 2019-09-30
    • 2012-11-27
    • 1970-01-01
    • 1970-01-01
    • 2010-12-13
    • 2018-02-27
    • 2011-01-13
    相关资源
    最近更新 更多