add git-lfs

This commit is contained in:
Malin Freeborn 2023-08-01 18:37:12 +02:00
parent 9b23c29735
commit 1a90265daf
Signed by: andonome
GPG Key ID: 52295D2377F4D70F
2 changed files with 101 additions and 0 deletions

BIN
slides/lfs/inferno.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 KiB

101
slides/lfs/lfs.md Normal file
View File

@ -0,0 +1,101 @@
# 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.
```text
2806 commits x 15MB = 41GB
```
# Initial Tactics: `.gitignore`
```
*.pdf
*.epub
Makefile
*.xcf
```
...but sometimes it's not enough.
# Saving Your Immortal Soul
![Well deserved fate](slides/lfs/inferno.png)
End the madness with git lfs.
# Setup
```bash
apt install -y git-lfs
cd $PROJECT
git lfs install
```
## Output: Easy Hooks
```bash
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:
```bash
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:
```bash
git lfs fetch origin --all
git lfs push $newRemote --all
```
# Problems
`soft-serve` does not yet support `git-lfs`.
(end list)