How to clone/pull a git repository, ignoring LFS?

ideasman42 picture ideasman42 · Feb 3, 2017 · Viewed 27.1k times · Source

Is there a way to explicitly ignore all git-lfs files on clone and pull?
(besides uninstalling git-lfs which I ended up doing).


In this case git-lfs just contains pre-compiled libs for a platform I don't use... so there is absolutely no use in getting them.

Answer

Two alternatives:

(1) Using the GIT_LFS_SKIP_SMUDGE variable:

GIT_LFS_SKIP_SMUDGE=1 git clone SERVER-REPOSITORY

Obs: for "Windows", use the following two commands:

set GIT_LFS_SKIP_SMUDGE=1  
git clone SERVER-REPOSITORY

(2) Configuring the git-lfs smudge:

git config --global filter.lfs.smudge "git-lfs smudge --skip -- %f"
git config --global filter.lfs.process "git-lfs filter-process --skip"
    
git clone SERVER-REPOSITORY

To undo this configuration, execute:

git config --global filter.lfs.smudge "git-lfs smudge -- %f"
git config --global filter.lfs.process "git-lfs filter-process"