Getting Started with LFS in GitLab
After having set up GitLab with LFS, I needed to install an LFS client in order to make use of it in my repository. On Ubuntu 18.04, this was as easy as running:
sudo apt-get install git-lfs -y
git clone ssh://email@example.com:23825/diverse-interactive/clients.diverseinteractive.com.git cd clients.diverseinteractive.com git lfs install
You should see:
Updated git hooks. Git LFS initialized.
To add items to be tracked by LFS, you would do something like:
git lfs track "*.mp4"
... which would ensure LFS was used for all of your mp4 files.
When you do this, a new entry is added to your
.gitattributes file and one is created if it doesn't exist yet. It will look something like:
*.mp4 filter=lfs diff=lfs merge=lfs -text lockable *.mp3 filter=lfs diff=lfs merge=lfs -text lockable ...
Be sure to add the .gitattributes file so that git tracks it.
git add .gitattributes git commit
You may wish to use the following command to list all the unique extensions of files that are larger than 1 Megabyte.
find . -type f -size +1M | perl -ne 'print $1 if m/\.([^.\/]+)$/' | sort -u
Because we are messing with binary files which cannot be diff-merged, we probably want to utilize locking.
Lock A File
git lfs lock images/banner.png
git lfs locks
Unlock A File
When you have finished editing a file that you locked, be sure to unlock it so others know they can edit it.
git lfs unlock images/banner.png
--force parameter, but this will only work if you have maintainer privileges on the repo.
First published: 25th June 2019