ID: I202512181300
Status: idea
Tags: git
Git LFS Cheatsheet
Initial Setup
Install Git LFS (one-time):
git lfs installThis registers Git LFS globally on your machine.
Initialize Git LFS in a repo:
git lfs track "*.pdf"
git lfs track "*.mp4"
git lfs track "*.psd"Creates .gitattributes file (commit this to the repo).
Track multiple file types at once:
git lfs track "*.{pdf,mp4,psd,zip}"View what’s being tracked:
git lfs ls-filesCloning & Pulling
Clone with LFS files (preferred):
git clone <repo-url>
git lfs install
git lfs pullClone without LFS files (pointer files only):
git clone <repo-url>Pull LFS files after cloning:
git lfs pull
git lfs pull --allFetch and checkout separately:
git lfs fetch --all
git lfs checkoutDaily Workflow
Push changes (includes LFS files):
git add .
git commit -m "message"
git pushGit automatically handles LFS files.
Pull updates:
git pull
git lfs pull⚠️ CRITICAL: Multi-Device Setup
You MUST do this on EVERY device using the repo:
- Install Git LFS:
git lfs install- Clone the repo:
git clone <repo-url>- Pull LFS files:
git lfs pullIf you forget on a device, you’ll only see pointer files (the version https://git-lfs.github.com/spec/v1 stubs) instead of actual files.
Troubleshooting
Check if LFS is installed:
git lfs versionSee pointer files instead of actual files:
git lfs install
git lfs pull
git lfs checkoutCheck LFS storage quota/usage:
git lfs logs lastRemove a file from LFS tracking:
git lfs untrack "*.pdf"
git add .gitattributes
git commit -m "Stop tracking PDFs with LFS"Migrate existing files to LFS:
git lfs migrate import --include="*.pdf"Key Points
.gitattributesmust be committed – share it with all team members- All collaborators need
git lfs install– or they get pointer files - LFS requires remote storage – GitHub, GitLab, Bitbucket, or self-hosted
- Large files should be tracked – PDFs, videos, images, binaries (>100MB)
- Small text files should NOT be in LFS – defeats the purpose
References
My pdfs didn’t load and showed this when i opened them:
oid sha256:2cf592be0098338078766687199555e24683660dbdeda00e6cd89a8639707fba
size 49133