Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

git-lfs

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.

like image 572
ideasman42 Avatar asked Feb 03 '17 08:02

ideasman42


People also ask

How do I clone a git repository LFS?

Once Git LFS is installed, you can clone a Git LFS repository as normal using git clone . At the end of the cloning process Git will check out the default branch (usually main ), and any Git LFS files needed to complete the checkout process will be automatically downloaded for you.

What is smudge in git LFS?

The Git smudge filter is what converts the LFS pointer stored in Git with the actual large file from the LFS server. If your local repository does not have the LFS object, the smudge filter will have to download it. This means that network issues could affect the smudge filter.


2 Answers

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"
like image 184
Marcelo Ávila de Oliveira Avatar answered Oct 28 '22 05:10

Marcelo Ávila de Oliveira


I'm currently struggling myself to find a clean way to download (and remove afterwards) large files with git-lfs.

However, there is a third alternative to the post of @Marcelo Ávila de Oliveira:

git lfs install --skip-smudge

will define globally to skip lfs downloads initially, when cloning repositories.


 

EDIT: I've created a tutorial for basic git-lfs handling. Any feedback and suggestions are very welcome.

You can find it at:

https://sabicalija.github.io/git-lfs-intro/

or pull it via:

git clone https://github.com/sabicalija/git-lfs-intro.git

like image 21
Alija Avatar answered Oct 28 '22 04:10

Alija