Git LFS Documentation

Git Large File Storage

Adding Large Files to Version Control with Git LFS

  1. Verify Git LFS is installed and initialized. Make sure git hooks are updated.
git lfs install
  1. Track the file types you want associated with Git LFS. This will update the .gitattributes file.
git lfs track "*.<file extension type>"
  • It is also good to commit the .gitattributes file to update the changes.
git add .gitattributes
git commit -m "<insert commit message>"
  1. You may need to rewrite the history to remove the original non-LFS commits of large files.
git rm --cached "<path to large file>"
git add .
git commit -m "<insert commit message>"
  1. Re-include the large file path for LFS handling.
git add "<path to large file>"
git commit -m "<insert commit message>"
  • Another alternative is to use LFS migrate to automate the process.
git lfs migrate import --include="*.<file extension type>"
  1. Lastly, push the latest commits to your remote origin.
git push origin main
  • Note that you may need to force push the commits and that the history may be rewritten.
git push origin main --force