1.4 KiB
1.4 KiB
The Horrifying Cost
If a Git has 2806 commits, and you commit 15MB worth of output each time, then you are a menace and must be stopped.
2806 commits x 15MB = 41GB
Initial Tactics: .gitignore
*.pdf
*.epub
Makefile
*.xcf
...but sometimes it's not enough.
Saving Your Immortal Soul
End the madness with git lfs.
Setup
apt install -y git-lfs
cd $PROJECT
git lfs install
Output: Easy Hooks
cat ~/.git/hooks/pre-push
#!/bin/sh
command -v git-lfs >/dev/null 2>&1 || { echo >&2
"This repository is configured for Git LFS but
'git-lfs' was not found on your path. If you no
longer wish to use Git LFS, remove this hook by
deleting '.git/hooks/pre-push'."; exit 2; }
git lfs pre-push "$@"
Add Files
Track all the files:
git lfs track "*.iso"
git lfs track "*.png"
git lfs track "*.jpg"
git lfs track "*.jpeg"
git lfs track "*.tiff"
git lfs track "*.xlsx"
git lfs track "*.docx"
cat .gitattributes
Result:
*.jpg filter=lfs diff=lfs merge=lfs -text
*.svg filter=lfs diff=lfs merge=lfs -text
Double check with git lfs ls-files
.
Locking
[ If your remote supports it ] lock your files when working on them.
Migration
Make sure you have all the files:
git lfs fetch origin --all
git lfs push $newRemote --all
Problems
soft-serve
does not yet support git-lfs
.
(end list)