Skip to content

Instantly share code, notes, and snippets.

@danmack
Created October 20, 2023 20:26
Show Gist options
  • Save danmack/4d924fdeb23c9b0a7bf1499b25561095 to your computer and use it in GitHub Desktop.
Save danmack/4d924fdeb23c9b0a7bf1499b25561095 to your computer and use it in GitHub Desktop.
Git LFS on Private Self-Signed GitLab Server

How to set up and work with an LFS repo

This writeup describes how to work with LFS on an internal / private gitlab server using self signed certificates.

Setting up your Git Software

Your git software (git cli command most likely) will need to have the git-lfs software installed. If you are on Ubuntu Linux, this add-on is available in the apt software repo, for example:

% sudo apt install git-lfs

Making sure it is available on your GitLab repo.

By default, LFS should be enabled on your repository already. If it is not, any owner or maintainer of the GitLab repository should be able to turn it on through the GitLab web interface by:

  • visiting the Settings menu for your project.
  • from the Settings menu, go to: General -> Visibility, project features, permissions
  • scroll down, you will see an option called: Git Large File Storage (LFS)
  • enable it if necessary by clicking the toggle switch

How to specify files that use LFS

This is pretty straightforward as the following example demonstrates:

cd existing-repo
git config http.sslVerify "false"
git lfs track "*.iso"
git lfs track "*.img"
git add .gitattributes
git commit -m 'Specify LFS file types'
git push origin main

I will explain why we set httpsslVerify to false shortly.

The commands above do the following:

  1. allow git LFS to work with a self signed certificate
  2. mark files ending in .iso and .img for LFS handling in a new file called .gitattributes
  3. we add the .gitattributes to our repo, commit, and push to main

Self Signed Certficate Workarounds are needed from here on out

Once you have a git repository on GitLab using a self signed certificate, you will need to make two slight changes to your behaviour when working with any repository that has LFS in use.

  1. When cloning the repository, you will need to clone like this:
GIT_SSL_NO_VERIFY="true" git clone gitlab:hw/bigstuff.git
  1. You need to set git's LOCAL scope configuration variable for the repository (just one time) like this:
git config http.sslVerify "false"

This allows SSL to work even though the certfificate we use inside is self-signed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment