简体   繁体   English

如何将现有的裸git存储库导入Gitlab?

[英]How to import an existing bare git repository into Gitlab?

I import my bare git repository into Gitlab as described as here , because it was not recognized as an git repository, but creates a 94K big 'empty' repo (the original is 2,8GB big): 导入我的裸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!

As a workaround I replace the empty project folder (which was created by import trial) with my bare repo. 作为一种解决方法,我用我的裸仓库替换空项目文件夹(由导入试用版创建)。 Afterwards I tree to clone the repo from remote and get the following error: 然后我树从克隆远程克隆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.

But the git user should have all rights which are needed. 但是git用户应该拥有所需的所有权限。 -Maybe I have something overlooked? - 也许我有一些被忽视的东西?

My System: RHEL6.3, Git 1.8.3.4, Gitlab5.3. 我的系统:RHEL6.3,Git 1.8.3.4,Gitlab5.3。

Does Gitlab need a normal repository (non-bare)? Gitlab需要一个普通的存储库(非裸)吗? Or what could be my problem? 或者我的问题是什么?

Does Gitlab need a normal repository (non-bare)? Gitlab需要一个普通的存储库(非裸)吗?

No, all repos managed by gitlab are bare repos. 不,由gitlab管理的所有回购都是裸回购。

You should see: 你应该看到:

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

Make sure the rights of your test.git folder (and bare repo files within it) are the same than the existing bare repos under /home/git/repositories/ . 确保test.git文件夹(以及其中的裸存储文件)的权限与/home/git/repositories/下的现有裸/home/git/repositories/

If the import doesn't work, then "replace the empty project folder (which was created by import trial) with my bare repo" should. 如果导入不起作用,那么“用我的裸仓库替换空项目文件夹(由导入试验创建)”应该。

But: you need to make sure any hook which was in the empty bare repo created by GitLab (in ~git/repositories/arepo.git/hooks ) is copied over your full bare repo replacing the empty one (same path). 但是:你需要确保GitLab创建的空裸~git/repositories/arepo.git/hooks中的任何钩子(在~git/repositories/arepo.git/hooks )被复制到你的完整裸~git/repositories/arepo.git/hooks替换空~git/repositories/arepo.git/hooks (同一路径)。
Check also what was in ~git/repositories/arepo.git/info and ~git/repositories/arepo.git/config 检查~git/repositories/arepo.git/info~git/repositories/arepo.git/config

To debug, try first to clone the empty bare repo created by GitLab during the failed import. 要进行调试,首先尝试克隆导入失败期间由GitLab创建的空裸存储库。
Then replace it with your own, double-check the hooks and try again. 然后用自己的替换它,仔细检查钩子然后再试一次。


As mentioned by the OP and documented in GitLab " Trouble Shooting Guide ", the correct ssh url is: 至于提到的OP和GitLab记录“ 故障排除指南 ”,正确的SSH网址是:

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

with :repositories mentioned. with :repositories提到的:repositories


To import bare repos (as mentioned by Sytse Sijbrandij below and in raketasks/import.md ) 导入裸存储库(如下面Sytse Sijbrandijraketasks/import.md

  • copy your bare repos under git repos_path (see config/gitlab.yml gitlab_shell -> repos_path ) 在git repos_path下复制你的裸存储库(参见config/gitlab.yml gitlab_shell -> repos_path
  • run the command below 运行以下命令

     bundle exec rake gitlab:import:repos RAILS_ENV=production 

For me the location to copy the repository is - /var/opt/gitlab/git-data/repositories 对我来说,复制存储库的位置是 - / var / opt / gitlab / git-data / repositories

I copied my existing bare repository in above dir and ran >gitlab-rake gitlab:import:repos it worked!!! 我在上面的dir中复制了我现有的裸存储库并运行> gitlab-rake gitlab:import:repos it working !!!

I have it! 我有它! It was a missing directory in my ssh path. 这是我的ssh路径中缺少的目录。 This issue was already tracked here . 此问题已在此处进行了跟踪。

Sorry, but the error messages were not so obviously. 对不起,但错误信息并不那么明显。 I hope this can help other Gitlab-beginners like me :) 我希望这可以帮助像我这样的其他Gitlab初学者:)

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

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