workshops/slides/lfs/lfs.md
2023-08-01 18:37:12 +02:00

102 lines
1.4 KiB
Markdown

# 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)