How to Install Git LFS: Step-by-Step Guide
To install
git lfs, download and run the installer for your operating system or use your package manager. After installation, run git lfs install once to set up Git LFS in your environment.Syntax
The basic syntax to install Git LFS depends on your operating system and package manager. After installing the software, you must run git lfs install to initialize it for your user account.
- Windows: Use the official installer or
choco install git-lfsif you have Chocolatey. - macOS: Use Homebrew with
brew install git-lfs. - Linux: Use your distro's package manager, e.g.,
sudo apt install git-lfsfor Debian/Ubuntu.
Then run:
git lfs install
This command sets up Git LFS hooks in your Git configuration.
bash
git lfs install
Output
Git LFS initialized.
Example
This example shows how to install Git LFS on macOS using Homebrew and initialize it.
bash
brew install git-lfs git lfs install
Output
==> Downloading https://formulae.brew.sh/api/formula.json
==> Installing dependencies for git-lfs: ...
==> Installing git-lfs...
==> Pouring git-lfs-3.3.0.catalina.bottle.tar.gz
==> Caveats
Git LFS initialized.
Common Pitfalls
Common mistakes when installing Git LFS include:
- Forgetting to run
git lfs installafter installation, which means Git LFS won't work properly. - Using outdated package managers or installers that install old versions.
- Not having Git installed before installing Git LFS.
- Not restarting your terminal or IDE after installation, so the new commands are not recognized.
bash
git lfs track "*.psd" # Wrong: If git lfs install was not run, this will not work properly # Right: git lfs install git lfs track "*.psd"
Quick Reference
| Command | Description |
|---|---|
| brew install git-lfs | Install Git LFS on macOS using Homebrew |
| sudo apt install git-lfs | Install Git LFS on Debian/Ubuntu Linux |
| choco install git-lfs | Install Git LFS on Windows using Chocolatey |
| git lfs install | Initialize Git LFS in your user environment |
| git lfs track " | Track large files matching the pattern |
Key Takeaways
Install Git LFS using your system's package manager or official installer.
Always run 'git lfs install' after installation to enable Git LFS hooks.
Make sure Git is installed before installing Git LFS.
Restart your terminal or IDE after installation to recognize Git LFS commands.
Use 'git lfs track' to specify which large files Git LFS should manage.