12

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):

$ 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:

$ 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. -Maybe I have something overlooked?

My System: RHEL6.3, Git 1.8.3.4, Gitlab5.3.

Does Gitlab need a normal repository (non-bare)? Or what could be my problem?

user2451418
  • 1,387
  • 4
  • 15
  • 27

4 Answers4

13

Does Gitlab need a normal repository (non-bare)?

No, all repos managed by gitlab are bare repos.

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/.

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

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.


As mentioned by the OP and documented in GitLab "Trouble Shooting Guide", the correct ssh url is:

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

with :repositories mentioned.


To import bare repos (as mentioned by Sytse Sijbrandij below and in 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
    
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • I have added my import error to my question, because I think the main problem is the import of my bare repo. The permissions I have checked several times and those are (drwxrws---.). – user2451418 Aug 14 '13 at 15:40
  • @user2451418 then your workaround should work... I have edited my answer with some more ideas to consider. – VonC Aug 14 '13 at 15:45
  • I think there are no hooks created:***post-receive hooks in repos are links: ... Gitlab / test ... repository is empty***. And the same with satellites. Also the problem does not disappear when i try to clone the empty repo from remote via ssh. But on the server cloning works fine. – user2451418 Aug 14 '13 at 16:40
13

For the documentation of this feature see https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/raketasks/import.md

Sytse Sijbrandij
  • 1,885
  • 2
  • 22
  • 20
  • Good Link. +1. i have included it in my selected answer for more visibility. – VonC Apr 30 '14 at 13:32
  • You will also want to consider: https://github.com/gitlabhq/gitlabhq/pull/8140 : only put your to be imported repos under a namespace (user or group subdir). – Ciro Santilli OurBigBook.com Oct 22 '14 at 22:38
  • I followed the instructions on the linked page and did not see my new project. Upon investigation it was because the project was internal and not visible to a user without admin privileges. Fixing the visibility fixed the issue. – Farrukh Najmi Mar 09 '17 at 15:36
4

For me the location to copy the repository is - /var/opt/gitlab/git-data/repositories

I copied my existing bare repository in above dir and ran >gitlab-rake gitlab:import:repos it worked!!!

JRomio
  • 2,407
  • 3
  • 26
  • 27
  • 3
    Doing this return the following error message : "Please specify an import path that contains the repositories". What worked was following https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/raketasks/import.md and escaping the `[` and `]` characters when using zsh. – Alex Apr 14 '18 at 00:48
3

I have it! It was a missing directory in my ssh path. 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 :)

user2451418
  • 1,387
  • 4
  • 15
  • 27
  • specific link - https://github.com/gitlabhq/gitlab-public-wiki/wiki/Trouble-Shooting-Guide#gitlab-shell – Anake Apr 10 '16 at 22:41