Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delete git LFS files not in repo

I uploaded some files to git LFS and I went over my storage limit. Now, the files I uploaded don't show up in the repo, but I'm still over my data limit and I can't upload anything.

like image 338
awesomeness872 Avatar asked Jun 11 '17 06:06

awesomeness872


People also ask

How do I remove LFS from a git repository?

Luckily, you can do this by using the filter-remote command. First, we’ll want to start by removing LFS from the repository by running git lfs uninstall in the root folder of the repository. Next, we’ll want to run a command to rewrite the history.

How do I safely remove Git-LFS?

Instantly share code, notes, and snippets. So, it has been an interesting journey, but time to remove git-lfs. Here follows a summary of the approach I used to safely remove git-lfs, remove lfs stuff from .gitattributes (open file, delete content - don't delete the file!) run a git status and make sure all the files were added properly

Is there a difference between Git-LFS and Git repo?

The given link to a github article is about large files directly checked into the git repo, which is NOT the same as git-lfs! As for the question: how this situation is handled depends on the underlying storage server. git-lfs support can be provided by different services, e.g. GitHub oder GitLab. GitLab stores git-lfs files not per repository.

Why are my files being added when I re-run Git add?

Even though Git LFS is configured in $HOME/.gitconfig, your repository doesn't have a .gitattributes telling Git to invoke Git LFS when you re-run git add, so your files are added as expected. Another caveat of this case is that you must have a local cache of all Git LFS objects for this to work, which you can accomplish by git lfs pull --all.


2 Answers

Deleting local Git LFS files You can delete files from your local Git LFS cache with the git lfs prune command:

$ git lfs prune

✔ 4 local objects, 33 retained

Pruning 4 files, (2.1 MB)

✔ Deleted 4 files

This will delete any local Git LFS files that are considered old. An old file is any file not referenced by:

  • the currently checked out commit
  • a commit that has not yet been pushed (to origin, or whatever lfs.pruneremotetocheck is set to)
  • a recent commit

for details please go through this link https://www.atlassian.com/git/tutorials/git-lfs

like image 196
Rohit Poudel Avatar answered Sep 22 '22 15:09

Rohit Poudel


Currently that is not possible via lfs command line. From the Atlassian Git LFS tutorial:

The Git LFS command-line client doesn't support pruning files from the server, so how you delete them depends on your hosting provider. In Bitbucket Cloud, you can view and delete Git LFS files via Repository Settings > Git LFS

GitHub even suggest recreating the repo:

To remove Git LFS objects from a repository, delete and recreate the repository. When you delete a repository, any associated issues, stars, and forks are also deleted.

But it is still good idea to use tools like BFG to clear out large files in history before moving around.

like image 44
hurturk Avatar answered Sep 24 '22 15:09

hurturk