Was Sie erreichen werden
Sie werden Git LFS installieren und fur ein Projekt mit Bildern, Video und Design-Dateien konfigurieren.
Schritt 1: Git LFS installieren
# macOS
brew install git-lfs
# Debian/Ubuntu
sudo apt install git-lfs
git lfs version
git lfs install
Schritt 2: in das Repo gehen
cd path/to/repo
git lfs install --local
Schritt 3: Dateitypen tracken
git lfs track "*.psd"
git lfs track "*.ai"
git lfs track "*.sketch"
git lfs track "*.mp4"
git lfs track "*.mov"
git lfs track "*.wav"
git lfs track "assets/raw/**"
Schritt 4: .gitattributes committen
git add .gitattributes
git commit -m "Configure LFS tracking for media files"
Schritt 5: neue Mediendateien hinzufugen
cp ~/Downloads/logo.psd assets/
git add assets/logo.psd
git commit -m "Add logo PSD"
git push
git lfs ls-files
Schritt 6: bestehende Binaries migrieren
git lfs migrate import --include="*.psd,*.mp4,*.mov,*.wav" --everything
git push --force --all
git push --force --tags
Schritt 7: binare Dateien sperren (optional)
# .gitattributes
*.psd filter=lfs diff=lfs merge=lfs -text lockable
*.ai filter=lfs diff=lfs merge=lfs -text lockable
git lfs lock assets/logo.psd
git push
git lfs unlock assets/logo.psd
git lfs locks
Schritt 8: auf einem frischen Klon verifizieren
cd /tmp
git clone <url> test-clone
cd test-clone
ls -la assets/logo.psd
git cat-file -p HEAD:assets/logo.psd
Schritt 9: Quoten handhaben
- Gitea oder Forgejo - LFS integriert.
- GitLab - LFS nativ.
- Bare LFS-Server.
Schritt 10: Pruning
git lfs prune
git lfs prune --dry-run
Performance-Tipps
- LFS-Smudge auf initialem Klon uberspringen.
git lfs fetch --recentin CI verwenden.- CI-Caches konfigurieren.
Fehlerbehebung
- Pointer-Datei im Working Tree: LFS nicht installiert.
- Push abgelehnt: Quote uberschritten.