Skip to main content

lfs-large-file-storage

https://git-lfs.com/

1

2

3

3

Setting Up and Using Git LFS on Windows 11 with Git Bash for Angular Web Apps

1. Install Git LFS

Open Git Bash and run:

git lfs install

2. Track Large Files

Decide which file types to track (e.g., images, videos, binaries):

git lfs track "*.png"
git lfs track "*.mp4"

This creates or updates a .gitattributes file.

3. Add and Commit Files

Add your large files and commit as usual:

git add .gitattributes
git add path/to/large-file.png
git commit -m "Add large files with LFS"

4. Push to Remote

Push your changes to your remote repository:

git push origin main

5. Clone with LFS

When cloning a repo with LFS files, run:

git clone <repo-url>
cd <repo-folder>
git lfs pull

6. Using with Angular Projects

  • Place large assets (e.g., images, videos) in a suitable folder (like src/assets/).
  • Track only necessary file types to avoid unnecessary LFS usage.
  • Ensure all team members have Git LFS installed.

7. Verify LFS Status

Check tracked files and LFS status:

git lfs ls-files

Resources

Common Issue: All Files Show as Changed After Enabling Git LFS

When you first enable Git LFS and start tracking new file types, Git may show all previously committed files of those types as "modified" in git status. This happens because .gitattributes has changed and Git wants to update the tracked files to use LFS pointers.

How to Resolve

  1. Clear the Git Index Cache

    After updating .gitattributes to track new file types, clear the Git index cache so Git recognizes the changes:

    git rm --cached -r .
    git add .
  2. Stage the Attribute Changes and Affected Files

    git add .gitattributes
    git add .
  3. Commit the Changes

    git commit -m "Migrate existing files to LFS"
  4. Push to Remote

    git push origin main

This updates the repository so that the specified file types are now managed by LFS, and the working directory is clean.