Git LFS is a command line extension for managing large files with Git. It replaces large files with text pointers inside your Git repository while storing the actual file contents separately.
To install Git LFS on Debian-based distributions, run:
sudo apt-get install git-lfs
For Red Hat-based distributions, you can use either dnf
or yum
:
sudo dnf install git-lfs
or
sudo yum install git-lfs
To install Git LFS on macOS using Homebrew:
brew install git-lfs
After installing Git LFS, you need to run the following command to configure it globally:
git lfs install
This step ensures Git is configured to work with LFS in all repositories.
Once Git LFS is installed and configured, you can begin tracking large files in your repository.
To track specific file types (for example, all .psd
files), use the git lfs track
command inside your repository:
git lfs track "*.psd"
This will create or update the .gitattributes
file in your repository. You should commit this change:
git add .gitattributes
git commit -m "Track PSD files using Git LFS"
You can now add and commit large files as you normally would:
git add myfile.psd
git commit -m "Add my PSD file"
Push your changes to a remote repository as usual. Git LFS will handle the large files automatically:
git push origin main
To verify that Git LFS is tracking your files, run:
git lfs ls-files
If you have large files already in your Git repository's history, you can migrate them to Git LFS using the following command:
git lfs migrate import --include="*.psd" --everything
⚠️ Note: This operation will rewrite your repository history and change Git object IDs.
If you decide to stop using Git LFS and want to convert your repository back to plain Git, you can use the following command:
git lfs migrate export --include="*.psd" --everything
- For additional help, refer to the official Git LFS documentation.
- If you run into issues or need help with specific commands, you can get help by running:
git lfs help <subcommand>