git-lfs cheat sheet
git-lfs cheat sheat

git-lfs cheat sheat

This is the procedure how to get git-lfs in working order if you have a Synology NAS. In case your Linux server does not run in a Synology VM, skip step 1 - in addition you have to adapt the lfs storage path in step 2 accordingly.

1. Configuration of Synology

  • Using DSM, create a new Linux VM, e. g. my_linux_vm

  • Using DSM, create a new user lfs with password lfs_password

  • Using DSM, make sure to register for the reverse DNS service synology.me, e. g. your_diskstation.synology.me

  • Give user lfs write access to the shared folder where you want to put the lfs file storage, e. g. Data

mkdir /volume1/Data/lfs
sudo vi /etc/nginx/sites-enabled/server
my_linux_vm.conv
server {
    listen 80;
    server_name lfs.your_diskstation.synology.me;
    error_log /var/log/nginx/lfs.access.log;
    root /var/services/web;
    location / {
        proxy_pass http://my_linux_vm:1234/; # ~/go/bin/lfs-test-server running on my_linux_vm on port 1234
        include proxy.conf;
        proxy_read_timeout 3600s;
        proxy_set_header Connection "Upgrade";
    }
}

(choose a port number that is nowhere used in your network; in this sample 1234)

2. Configuration of Linux server

sudo apt-get install golang-go
go get github.com/github/lfs-test-server
cd ~/go/bin
vi run.sh
#!/bin/bash

set -eu
set -o pipefail

LFS_LISTEN="tcp://:1234"
LFS_HOST="lfs.your_diskstation.synology.me"
LFS_CONTENTPATH="/media/lfs"
LFS_ADMINUSER="Admin"
LFS_ADMINPASS="your_lfs_password"

export LFS_LISTEN LFS_HOST LFS_ADMINUSER LFS_ADMINPASS LFS_CONTENTPATH
cd ~/go/bin
./lfs-test-server
chmod +x run.sh
sudo crontab -e
@reboot /home/stefan/go/bin/run.sh
mkdir /media/lfs
sudo vi /etc/fstab
      //your_diskstation/Data/lfs      /media/lfs      cifs    username=lfs,password=your_lfs_password   0       0
mount -a # reload fstab

3. Configuration of git-lfs

  • Browse to http://lfs.your_diskstation.synology.me/mgmt

  • Authenticate with Admin/your_lfs_password

  • Click on Users

  • Create new user

4. Configuration of git repo

git config -f .lfsconfig lfs.url http://lfs.your_diskstation.synology.me
git add .lfsconfig
vi .gitattributes
*.a     filter=lfs diff=lfs merge=lfs -text
*.cat   filter=lfs diff=lfs merge=lfs -text
*.cpl   filter=lfs diff=lfs merge=lfs -text
*.dll   filter=lfs diff=lfs merge=lfs -text
*.dylib filter=lfs diff=lfs merge=lfs -text
*.docx  filter=lfs diff=lfs merge=lfs -text
*.fwc   filter=lfs diff=lfs merge=lfs -text
*.exe   filter=lfs diff=lfs merge=lfs -text
*.gz    filter=lfs diff=lfs merge=lfs -text
*.jpg   filter=lfs diff=lfs merge=lfs -text
*.key   filter=lfs diff=lfs merge=lfs -text
*.lib   filter=lfs diff=lfs merge=lfs -text
*.msi   filter=lfs diff=lfs merge=lfs -text
*.tar   filter=lfs diff=lfs merge=lfs -text
*.odg   filter=lfs diff=lfs merge=lfs -text
*.ods   filter=lfs diff=lfs merge=lfs -text
*.odt   filter=lfs diff=lfs merge=lfs -text
*.pages filter=lfs diff=lfs merge=lfs -text
*.pap   filter=lfs diff=lfs merge=lfs -text
*.pbf   filter=lfs diff=lfs merge=lfs -text
*.pdf   filter=lfs diff=lfs merge=lfs -text
*.pkg   filter=lfs diff=lfs merge=lfs -text
*.png   filter=lfs diff=lfs merge=lfs -text
*.run   filter=lfs diff=lfs merge=lfs -text
*.so    filter=lfs diff=lfs merge=lfs -text
*.sys   filter=lfs diff=lfs merge=lfs -text
*.tar   filter=lfs diff=lfs merge=lfs -text
*.tif   filter=lfs diff=lfs merge=lfs -text
*.zip   filter=lfs diff=lfs merge=lfs -text
*.7z    filter=lfs diff=lfs merge=lfs -text
git add .gitattributes
git config --global credential.helper 'store'

On first commit authenticate with the user you specified in the git-lfs configuration