0

So I am trying to backup my gitlab repository FILES. I looked in the /var/opt/gitlab/git-data/repositories location and found the repos but the actual content of the repositories i.e.: the source codes are not there, just config files, HEAD files info, objects and refs folder etc.

can anyone tell me where on my server the actual files are stored?

I have lost the frontend ui of gitlab so cannot access it over the browser and need to download my source codes from the server.

Thanks.

Sunny Gohil
  • 319
  • 1
  • 11
  • 2
    These are `bare` repositories - to access the files stored within, you need to clone that path somewhere else. – match Apr 23 '18 at 10:14
  • i cant clone anything right now because i have issues in the server which is why i need to download the source code files manually. So where are the source code files stored then? Surely they must be stored somewhere? or am i missing something here? – Sunny Gohil Apr 23 '18 at 10:16
  • 1
    Possible duplicate of [What is the difference between "git init" and "git init --bare"?](https://stackoverflow.com/questions/7861184/what-is-the-difference-between-git-init-and-git-init-bare) – phd Apr 23 '18 at 11:11

1 Answers1

2

Those are the actual files, in Git's internal form.

Remember, Git stores every version of every file saved in every commit. To pull off this trick, it stores them in a form that is not useful to other (non-Git) programs, nor (directly) to you.

To extract files in a form that is useful to you and to other computer programs, you must git checkout some particular commit. When you do this, you have Git populate what Git calls a work-tree, which is where you do your work. Git fills in this work-tree (using Git's index, which I will mention but not explain here, as this gets a bit complicated) from the one specific commit you select. Hence, the contents of this work-tree will depend on which commit you select.

A --bare repository is (defined as) one that has no work-tree, so that you cannot work in it. This makes it suitable to receive incoming git push requests, which would otherwise potentially disturb the work someone might be doing. Without a work-tree, no one can possibly work in it, so there is no work that can be disturbed. But this also means you cannot select one commit and get its files in a work-tree, since there is no work-tree.

There are ways to view or extract files from each commit stored in a bare repository, but they are a bit tricky to use. For instance, git archive can turn a commit into an archive (tar or zip) that you can extract elsewhere. Remember that you'll generally get just one commit at a time when you ask for it.

torek
  • 448,244
  • 59
  • 642
  • 775