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/
. I have Gitlab CentOS rpm up and running on that same server now at http://testvps.subdomain.domain.com:8888
Import Local Master Repo into 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. This repo is the master branch NOT the original branch origin which is ZendApplication on Github. 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/
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 . 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. 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.
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 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
المحلول 3
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. Somehow during the installation of Gitlab this was not taken care of. 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. 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
نصائح أخرى
You might want be able to use rake gitlab:import:repos:
- copy the bare repository under
repos_path
(/home/git/repositories/group/repo.git
). Directory name must end in.git
and be under a group or user namespace. - run
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?
ONCE YOU HAVE SORTED YOUR USER ACCESS ISSUES:
- Create a new project on GitLab with the same name as your local project.
- On your local do:
git remote add origin git@repo-url:projectpath/projectname.git
git push