On my Ubuntu system, I installed Git LFS as well as Git, and cloned a repo that has some of its files managed by Git LFS. But those files didn't download, other than a marker file. (I didn't realize they weren't the whole file until I checked the file size, because they displayed in my file system with the right names, in the right places.)
I see from this answer that git lfs clone
has been deprecated, and simply git clone
should work. But when I tried that I got confused. I am used to just running git clone https://foobar.git
and letting it set up the directory. But Git LFS won't work unless it has been initialized with git lfs install
in each directory where it is being used. (That's why this didn't work the first time, at least now I know that.)
So I set up the directory, ran git init
and git lfs install
inside it, and then ran git clone https://foobar.git
. Which will create a directory for the repo nested inside the directory I created, will it not? That seems wrong somehow.
It is going to take a few hours to clone this repo, so I would like to be confident I'm doing this right. Looking at the documentation on GitHub, it seems to say the above set of commands is correct - if you read the whole thing. The bits of information are separated by a thousand words or so. Is that the way to do it?
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.
The idea is to use the git-clone to clone the repository. This will automatically fetch all the branches and tags in the cloned repository. To check out the specific branch, you can use the git-checkout command to create a local tracking branch.
Git LFS stores the binary file content on a custom server or via GitHub, GitLab, or BitBucket's built-in LFS storage. To find the binary content's location, look in your repository's . git/lfs/objects folder.
git lfs install
does two things: it sets up hooks in your local repository, and it adjusts your global (i.e., user-specific) configuration to contain the filter commands necessary for Git LFS to work properly.
If you're not in a repository yet, you probably want to run git lfs install --skip-repo
and let it install the filter commands into your ~/.gitconfig
. If you manage this file yourself, copy the lines that it adds into the one that you manage. Then, move into a non-Git-controlled directory and run git lfs env
and make sure that the last few lines look like this:
git config filter.lfs.process = "git-lfs filter-process"
git config filter.lfs.smudge = "git-lfs smudge -- %f"
git config filter.lfs.clean = "git-lfs clean -- %f"
That will show you that your configuration is set up properly. Once you have that set up, simply clone the repository, and assuming it's set up with the proper entries in its .gitattributes
file, Git will automatically pull down the Git LFS files necessary, and when Git LFS is invoked, it will install the necessary hooks.
On Debian, the Git LFS package installs the filter commands by default, so it probably does the same on Ubuntu. You can check for the entries in /etc/gitconfig
, and if they're present, you won't need to do anything at all; things should just work, and git lfs env
will automatically show you the right thing without any setup.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With