0

Background:

GitLab CE is installed on a personal Ubuntu server.

Problem:

As per GitLab's documentation here, the default path for storing git files is var/opt/gitlab/git-data, however when I access this file, it does not really have the files from my repository. It has .git files, which I don't know what they are and is no what I am looking for.

For example, if my repository is named hard_work, then when I ls with:

sudo ls /var/opt/gitlab/git-data/repositories/data/hard_hork.git

I find:

HEAD  config  description  gitlab-worktree  hooks  hooks.old.1260608859  info  language-stats.cache  objects  packed-refs  refs

Question:

Where are the actual contents of my repository (the files and folders which I see when I git clone or via the web browser.

Newskooler
  • 3,973
  • 7
  • 46
  • 84
  • 1
    Your .git directory IS your repository, just a bare repository. If you git clone it you get your latest version. – djuarezg Jun 24 '19 at 15:35

1 Answers1

1

As mentioned by someone else in the comment, what you're seeing with ls is the bare repository. See this post one the difference between bare and non-bare repository.

If you want to be able to browse the bare repository directly on your server (not sure why you would want to do that if you can access the repository on gitlab), you can use git ls-tree to list the files and git cat-file to inspect the objects:

sudo git --git-dir /var/opt/gitlab/git-data/repositories/data/hard_hork.git ls-tree --full-tree -r master
sudo git --git-dir /var/opt/gitlab/git-data/repositories/data/hard_hork.git git-cat -p <blob>

In case you need to use the scripts from your repository on the Ubuntu Server, you should clone the repository somewhere on the server, that way you will be able to see the files. Note that the cloned folder will not be "synchronized" with the GitLab repository, you will need to update it manually (or in your cron job).

piarston
  • 1,685
  • 1
  • 13
  • 25
  • Let's say on the server I have some cron jobs which use scripts from the gitlab repository. That's one reason I would like to be able to access the files (and know their path). I get the feeling I am thinking about this in the wrong way ... – Newskooler Jun 25 '19 at 07:12
  • Indeed I don't recommend to use the scripts directly from `git-data/`. You should deploy your scripts to your server (many approaches possible here). – piarston Jun 25 '19 at 07:48
  • Thank you. Can you please point me to a guide or something about deployment? Should this be done through the Ci/Cd? – Newskooler Jun 25 '19 at 08:38
  • 1
    Yes it could be deployed using Ci/Cd, although it is really hard to say without context. Maybe you can have a look at [this](https://gitolite.com/deploy.html) and [that](https://www.freelock.com/blog/john-locke/2015-06/case-git-deployment-tool). – piarston Jun 25 '19 at 08:46