简体   繁体   English

将现有的本地Git主存储库导入到Gitlab:Git用户访问问题

[英]Import Existing Local Git Master Repo into Gitlab: Git user Access Issues

I have a git master branch on my test server under testvps.subdomain.domain.com:~public_html/domain.com/ZendSkeletonApplication/ . 我在测试服务器上的testvps.subdomain.domain.com:~public_html/domain.com/ZendSkeletonApplication/下有一个git master分支。 I have Gitlab CentOS rpm up and running on that same server now at http://testvps.subdomain.domain.com:8888 我现在在http://testvps.subdomain.domain.com:8888上启动了Gitlab CentOS rpm并在同一台服务器上运行

Import Local Master Repo into Gitlab 将本地主仓库导入Gitlab

I need to import this existing local repository into Gitlab (See earlier question on cloning the repo here with ssh. ) on the same test server. 我需要导入这个现有的本地仓库到Gitlab(参见克隆回购较早前的问题在这里使用ssh)相同的测试服务器上。 This repo is the master branch NOT the original branch origin which is ZendApplication on Github. 此仓库是主分支,而不是Github上的ZendApplication的原始分支源。 For passworded access Gitlab suggested a link like https://username:password@gitlab.com/company/project.git Documentation mentions to copy bare repos to /home/git/ 对于密码访问,Gitlab建议使用类似https://username:password@gitlab.com/company/project.git的链接。文档提及将裸仓库复制到/ home / git /

What is the best approach? 最好的方法是什么?

The user git has been added only somehow the home directory was not created I guess that has to be done manually - see link here . 仅以某种方式添加了用户git,但未创建主目录,我想必须手动完成,请参见此处的链接。 Not sure if this is needed for proper imports though. 但不确定是否需要正确导入。 And this being a master branch would require a different approach to import the existing git repository with 20+ commits it seems. 而这是一个master分支,似乎需要使用不同的方法来导入具有20多个提交的现有git存储库。 Perhaps I should make the master a new origin? 也许我应该使大师成为一个新人? How should I go about doing this? 我应该怎么做呢?

Update 更新资料

I have added gitlab .git repo as new remote. 我已经添加了gitlab .git repo作为新的远程服务器。

git remote set-url origin git@testvps.sub.domain.com:root/repo.git
git remote -v
origin  git@testvps.sub.domain.com:root/repo.git (fetch)
origin  git@testvps.sub.domain.com:root/repo.git (push)

When I try to push to it I get a request for the password for the git user 当我尝试推送到它时,我收到了git用户的密码请求

git push -u origin master
git@testvps.sub.domain.com's password: 

which is not supposed to be needed nor do I have it. 不需要,我也没有。 How can I fix this? 我怎样才能解决这个问题?

PS sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production does not work as it mentions bundle as command is missing PS sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production不起作用,因为它提及缺少命令的捆绑

You might want be able to use rake gitlab:import:repos : 您可能希望能够使用rake gitlab:import:repos

  • copy the bare repository under repos_path ( /home/git/repositories/group/repo.git ). 将裸仓库复制到repos_path/home/git/repositories/group/repo.git )下。 Directory name must end in .git and be under a group or user namespace. 目录名称必须以.git结尾,并且在组或用户命名空间下。
  • run bundle exec rake gitlab:import:repos 运行bundle exec rake gitlab:import:repos

The owner will the first admin, and a group will get created if not already existent. 所有者将是第一个管理员,如果尚不存在,将创建一个组。

See also: How to import an existing bare git repository into Gitlab? 另请参阅: 如何将现有的裸git存储库导入Gitlab?

ONCE YOU HAVE SORTED YOUR USER ACCESS ISSUES: 一旦您解决了用户访问问题:

  1. Create a new project on GitLab with the same name as your local project. 在GitLab上创建一个与本地项目同名的新项目。
  2. On your local do: git remote add origin git@repo-url:projectpath/projectname.git 在您本地执行: git remote add origin git@repo-url:projectpath/projectname.git
  3. git push

With the help of another server admin I worked things out. 在另一个服务器管理员的帮助下,我解决了问题。 I need to generate and add a ssh key as described here http://www.codeproject.com/Articles/674637/How-to-passwordless-ssh for example. 我需要生成并添加ssh密钥,例如,例如http://www.codeproject.com/Articles/674637/How-to-passwordless-ssh Somehow during the installation of Gitlab this was not taken care of. 不知何故,在安装Gitlab的过程中并没有解决这个问题。 So a key was generated and added to authorized keys: 这样就生成了一个密钥并将其添加到授权密钥中:

ssh-keygen -t rsa
Generating public/private rsa key pair.
//store in home directory of user and then copy to authorized keys at destination
cat /user/.ssh/id_rsa.pub >>  /var/opt/gitlab/.ssh/authorized_keys

Also, the path to the Gitlab repo was not correct. 另外,通往Gitlab存储库的路径也不正确。 All repos are located here: /var/opt/gitlab/git-data/repositories/ and my repo was under my user - jasper for now - and thus git@testvps.domain.com:/var/opt/gitlab/git-data/repositories/jasper/repo.git 所有存储库都位于此处: /var/opt/gitlab/git-data/repositories/ ,我的/var/opt/gitlab/git-data/repositories/由我的用户使用- git@testvps.domain.com:/var/opt/gitlab/git-data/repositories/jasper/repo.git因此git@testvps.domain.com:/var/opt/gitlab/git-data/repositories/jasper/repo.git

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

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