如何将现有的裸 git 存储库导入 Gitlab?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18214363/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to import an existing bare git repository into Gitlab?
提问by user2451418
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 [email protected]:...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. -Maybe I have something overlooked?
但是 git 用户应该拥有所需的所有权限。- 也许我忽略了什么?
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)? Or what could be my problem?
Gitlab 是否需要一个普通的存储库(非裸)?或者我的问题是什么?
采纳答案by VonC
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/
.
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).
Check also what was in ~git/repositories/arepo.git/info
and ~git/repositories/arepo.git/config
但是:您需要确保由 GitLab (in ~git/repositories/arepo.git/hooks
)创建的空裸仓库中的任何钩子都复制到您的完整裸仓库上,替换空仓库(相同路径)。
检查还什么在~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.
Then replace it with your own, double-check the hooks and try again.
要进行调试,请首先尝试克隆在导入失败期间由 GitLab 创建的空裸仓库。
然后用你自己的替换它,仔细检查挂钩并重试。
As mentionedby the OPand documented in GitLab "Trouble Shooting Guide", the correct ssh url is:
正如OP所提到的,并在 GitLab“疑难解答指南”中记录,正确的 ssh url 是:
[email protected]:repositories/mygroup/proj1.git
with :repositories
mentioned.
与:repositories
提到。
To import bare repos (as mentioned by Sytse Sijbrandijbelowand in raketasks/import.md
)
导入裸仓库(如下面和中的Sytse Sijbrandij所述raketasks/import.md
)
- copy your bare repos under git repos_path (see
config/gitlab.yml
gitlab_shell -> repos_path
) run the command below
bundle exec rake gitlab:import:repos RAILS_ENV=production
- 在 git repos_path 下复制您的裸仓库(请参阅
config/gitlab.yml
gitlab_shell -> repos_path
) 运行下面的命令
bundle exec rake gitlab:import:repos RAILS_ENV=production
回答by Sytse Sijbrandij
For the documentation of this feature see https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/raketasks/import.md
有关此功能的文档,请参阅https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/raketasks/import.md
回答by JRomio
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!!!
我在上面的目录中复制了我现有的裸存储库并运行 >gitlab-rake gitlab:import:repos 它工作了!!!