-
Notifications
You must be signed in to change notification settings - Fork 0
LFS
git lfs install does the following:
- Adds pre-push hook to
.git/hooks.
post-checkout
post-commit
post-merge
pre-push
- Adds the following configurations to
<repository>/.git/.gitconfig.
[filter "lfs"]
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
required = true
- Creates
.git/lfs, which is a local cache.
Instead add this config to your global git config $HOME/.gitconfig.
git config --global filter.lfs.required true
git config --global filter.lfs.clean "git-lfs clean -- %f"
git config --global filter.lfs.smudge "git-lfs smudge -- %f"
git config --global filter.lfs.process "git-lfs filter-process"You won’t have to initialize LFS every time you clone a repository.
LFS has the batch mode for downloading files from a server. But it does not work on clone and checkout due to limitation of git’s smudge filters. You can skip LFS’s smudge filter and fetch LFS objects on demand.
For that:
- Change the smudge filter configuration:
git config --global filter.lfs.smudge "git-lfs smudge --skip %f"
git config --global filter.lfs.process "git-lfs filter-process --skip"
# Or by using
git lfs install --force --skip-smudgeRun git lfs env and be sure that the smudge filter is skipped.
- Fetch LFS objects after checkout or clone:
# downloads objects with batch mode
git lfs fetch
# changes objects to binary files
git lfs checkout # downloads lfs files one by one
git clone
# downloads faster in batch
git lfs clone
# pull and download lfs
git pull
# will download files in batch
git lfs pull
git lfs fetch
git lfs fetch --all
git lfs fetch --recent
# download Git LFS content for branches or tags updated in the last 10 days
git config lfs.fetchrecentrefsdays 10
git lfs push --all # Run from project root dir
git lfs track "*.ogg"
git lfs track "*.psd" --lockable
# List tracked files
git lfs track
# You can edit this file manually
cat .gitattributes
*.ogg filter=lfs diff=lfs merge=lfs -text
*.psd filter=lfs diff=lfs merge=lfs -text lockable
# Verify which files are being tracked by LFS
git lfs ls-filesCommit .gitattributes file
Locking API is still experimental, and not many providers implemented it.
git lfs track "*.psd" --lockableOnce file patterns in .gitattributes are lockable, LFS will make them readonly on the filesystem.
git lfs lock images/foo.psd
git lfs unlock images/foo.psd
git lfs unlock images/foo.psd --force # deletes **Old** files from cache
git lfs pruneOld files is not
- current commit
- recent commit
- not pushed changes
Recent commit is, by adding:
- the value of the
lfs.fetchrecentrefsdaysproperty - the value of the
lfs.pruneoffsetdaysproperty (which defaults to three)
# Look what will be deleted
git lfs prune --dry-run —-verbose
# Will verify if remote has files before prune
git lfs prune --verify-remote
git config --global lfs.pruneverifyremotealways true
# Find filename by Hash ID
git log --all -p -S <OID>
# find a particular object by OID in HEAD
$ git grep 3b6124b8b01d601fa20b47f5be14e1be3ea7759838c1aac8f36df4859164e4cc HEAD
HEAD:Assets/Sprites/projectiles-spritesheet.png:oid sha256:3b6124b8b01d601fa20b47f5be14e1be3ea7759838c1aac8f36df4859164e4cc
# find a particular object by OID on the "power-ups" branch
$ git grep e88868213a5dc8533fc9031f558f2c0dc34d6936f380ff4ed12c2685040098d4 power-ups
power-ups:Assets/Sprites/shield2.png:oid sha256:e88868213a5dc8533fc9031f558f2c0dc34d6936f380ff4ed12c2685040098d4 # Exclude files during fetch
git lfs fetch -X "Assets/**"
# Include files
git lfs fetch -I "*.ogg,*.wav"
# Exclude and Include
git lfs fetch -I "Assets/**" -X "*.gif"
git config lfs.fetchinclude "Assets/**"
git config lfs.fetchexclude "*.gif"Change your remotes’ protocols to ssh, so you will not need to use git’s credential-cache. Otherwise, you have to type login and password for every file you download from the GH media server.
- Remove LFS client configurations from
.gitconfig. It can be checked easily bygit lfs env - Reset branch
- Add configuration back
git lfs env
GIT_TRACE=1 git lfs <cmd>
git lfs logs last