Loading...

How to delete files from Git LFS and move them to normal Git Storage?

question devtips git
Ram Patra Published on March 21, 2025

Git does not automatically move files back to normal Git storage after you untrack them from LFS. Here’s what happens when you untrack a file:

  1. Git LFS still stores the file
    • The LFS object (the actual file) remains in .git/lfs/objects locally and on GitHub’s LFS storage.
    • Git still tracks the file as a pointer file (a small text file with a hash).
  2. The file is NOT automatically added to normal Git storage
    • Untracking only stops future commits from using LFS, but previously committed LFS objects remain in history.

How to Move a File Back to Normal Git Storage

To store the file as a normal Git file instead of an LFS pointer:

1. Untrack the file from LFS

git lfs untrack "path/to/file"

Then, remove the .gitattributes entry related to it.

2. Remove LFS-tracked file from Git history

Run:

git rm --cached "path/to/file"

This removes the LFS reference but keeps the file locally.

3. Recommit the file as a normal Git file

git add "path/to/file"
git commit -m "Re-adding file as a normal Git file"
git push origin main

Now, Git will store the full file instead of an LFS pointer.

4. Clean Up LFS Storage (Optional)

If you no longer need the file in LFS:

git lfs prune

To fully remove it from GitHub’s LFS storage, you need to rewrite history using git filter-repo and force push.

How to completely remove the file from Git LFS

1. Clone a fresh copy:

git clone --mirror https://github.com/YOUR-USERNAME/YOUR-REPO.git
cd YOUR-REPO.git

2. Run the git filter-repo command:

git filter-repo --path "path/to/file" --invert-paths

3. Push the cleaned repo back to GitHub:

git push origin --force --mirror
Presentify

Take your presentation to the next level.

FaceScreen

Put your face and name on your screen.

ToDoBar

Your to-dos on your menu bar.

Ram Patra Published on March 21, 2025
Image placeholder

Keep reading

If this article was helpful, others might be too

question devtips app-store September 29, 2024 How to add a bullet point in app descriptions for the Mac App Store?

To add a bullet point (•) in app descriptions for the Mac App Store, follow these steps:

question devtips chromium August 27, 2020 How to take screenshots of the entire webpage without any extensions?

I always used an extension like Awesome Screenshot in Chrome to take screenshots of any website. However, you do not need an extension to capture a screenshot of a webpage.

question devtips git September 22, 2024 How to upload large files to a git repository?

By default, you cannot upload files larger than ~100MB (for most Git hosting service providers). If you do so, the git push command will fail with an error. The recommended way to work with large files is to use Git LFS.

Like my work?

Please, feel free to reach out. I would be more than happy to chat.