1

I have a GitLab on my server, and of course Git as my repository system.

But I have problem integrating them with each other. It looks like I am creating project in GitLab and add README file (repositories are stored as I see in /var/opt/gitlab/git-data/repositories).

So project should be created in repository /var/opt/gitlab/git-data/repositories/wojsza, all I see in this folder is project name with git extension (in this case playground.git).

When I try to do git status or git remote -v I am getting

fatal: not a git repository (or any of the parent directories): .git

Same thing if I try to clone it (git clone git@example.com:wojsza/playground.git)

fatal: 'wojsza/playground.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 when I making some new repository manuall using git init in my home folder it works and I can clone it, but it is not recognized in GitLab.

What could be the source root of this problem.

  • The folders named something.git are (supposed to be) Git repositories. They’re bare repositories, of course. – Daniel B Feb 20 '19 at 14:16
  • Maybe you can't clone it because it's empty initially. Try to add it as a remote to some other repo and push to it. – gronostaj Feb 20 '19 at 14:22
  • 1
    I am unclear about where you are creating the project and what the server has to do with anything. A Git-related server is just a server you push and pull to. A local repository is a local repository. Peeking into /var/opt/gitlab/git-data/repositories is not something you would ever do in normal operations. – Giacomo1968 Feb 20 '19 at 14:57
1

This is not how you (usually) use a Gitlab repository, or any web-hosted Git repo (Gitlab, Github, Bitbucket...)

The Gitlab repo is intended to be used as a remote, not a local repository.

On the Gitlab project homepage, there is a "Clone" button. It contains an URL, SSH or HTTPS (or both) depending on your Gitlab config. This URL must be used on your computer in a git clone command in order to create a local instance of the project, you can then issue git push and git pulls to send your modifications to the Gitlab repo.

Here, on the Gitlab page for Gitlab CE:

"Clone" button on the right side of the project page


Edit

Another cool thing: depending on your Gitlab config, you can create a local git repo on your computer with git init, then ad a non-exisiting Gitlab project as a remote with

git remote add origin https://gitlab.example.com/path/to/repo.git

Then on the first git push, the corresponding Gitlab project and repo will be created. It depends on your Gitlab config and may not be authorized on your instance. And you may need to explicitely specify the branch to push since your local branch will not have any tracking/remote branch set.

| improve this answer | |
-2

I had the same problem and I solved it by giving the whole URL while cloning repo. In your case: git clone git@example.com:/var/opt/gitlab/git-data/repositories/wojsza/playground.git

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.