9

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

Community
  • 1
  • 1
rhand
  • 1,176
  • 4
  • 17
  • 45
  • 1
    What happens if you go to add a new repository in the GitLab front end and give it the URL of the existing repository? – orbrey Jul 29 '14 at 13:05
  • I cloned the repo before locally using `git clone me@testvps.sub.domain.com:~/public_html/domain.com/ZendSkeletonApplication/` But do you mean I should add the master branch as a remote using: `git remote add origin http://testvps.sub.domain.com/root/repo.git`? Current remote is Zend at Github: `git remote -v origin git://github.com/zendframework/ZendSkeletonApplication.git (fetch) origin git://github.com/zendframework/ZendSkeletonApplication.git (push)` Also wondering if I should make my master branch the origin instead to make things easier.. – rhand Jul 30 '14 at 07:25
  • Just using the url to import the existing repo failed. Cloning done before was done via the shell. Not sure yet how I can do it now. Thought it might work as the repo is on the same server, but as this is a http request it does not of course. And I read this: `You won't be able to pull or push project code via SSH until you add an SSH key to your profile` – rhand Jul 30 '14 at 07:46
  • Reading on adding local remotes here: http://stackoverflow.com/questions/5149872/how-to-git-remote-add-and-track-a-branch-in-the-same-filesystem – rhand Jul 30 '14 at 09:18
  • I could add the Gitlab repo as a new origin under a different name as explained here: http://stackoverflow.com/questions/11690709/can-a-project-have-two-origins-in-git . So something like `cd existing_git_repo git remote add new-name http://testvps.subdomain.domain.com/root/repo.git git push -u new-name master` . But I wonder if that would wipe out the current master branch or not.. – rhand Jul 30 '14 at 09:38
  • 1
    You could just substitute localhost in the URL for the http checkout via gitlab? – orbrey Jul 30 '14 at 10:36
  • http://localhost:~/public_html/domain.com/ZendSkeletonApplication/ did not work. localhost did not work. Repo is not big. Something else must be the issue. Wonder how to debug this. Gitlab access and error logs do not report issues at `/var/log/gitlab/nginx/gitlab_error.log` or `/var/log/gitlab/nginx/gitlab_access.log`. – rhand Jul 30 '14 at 12:54
  • Saw this error xx.xxx.xx.xxx - - [30/Jul/2014:14:46:42 +0200] "GET /public_html/domain.com/ZendSkeletonApplication/info/refs?service=git-upload-pack HTTP/1.1" 404 2529 "-" "git/1.8.5.3"on using link http://testvps.subdomain.domain.com:~/public_html/domain.com/ZendSkeletonApplication/ – rhand Jul 30 '14 at 12:57
  • Checking this http://stackoverflow.com/questions/17211665/git-update-server-info-nothing-do perhaps permission issues. – rhand Jul 30 '14 at 13:06
  • /public_html/domain.com/ZendSkeletonApplication/info/refs does not exist on the server and that is what git-upload-pack is looking for. There is a .git/info but even inside this folder there is no refs folder. This must be part of the import failure issue when using url http://testvps.subdomain.domain.com:~/public_html/domain.com/ZendSkeletonApplication/ – rhand Jul 30 '14 at 13:41
  • updated question. I added the new Gitlab rep as remote. Only now I need a password for the git user, which should not occur nor do I have this. Looking into storing key for passwordless login as I think this is the key here now – rhand Aug 05 '14 at 12:56

3 Answers3

4

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?

Community
  • 1
  • 1
Ciro Santilli OurBigBook.com
  • 347,512
  • 102
  • 1,199
  • 985
1

ONCE YOU HAVE SORTED YOUR USER ACCESS ISSUES:

  1. Create a new project on GitLab with the same name as your local project.
  2. On your local do: git remote add origin git@repo-url:projectpath/projectname.git
  3. git push
slonik
  • 1,144
  • 11
  • 13
0

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

Colonel Thirty Two
  • 23,953
  • 8
  • 45
  • 85
rhand
  • 1,176
  • 4
  • 17
  • 45