Git-lfs: How to remove LFS completely in my repository?

Created on 22 Dec 2015  路  24Comments  路  Source: git-lfs/git-lfs

Download LFS tracked files always fail. The log shows "dial tcp: i/o timeout". Maybe the cloud service used by LFS is unsuitable for me (A Chinese guy).

I guess I wouldn't use LFS anymore. How could I remove LFS in my repository?

Most helpful comment

@technoweenie I feel like if I'm going to be ping'd via email to upgrade and purchase space if I tried the feature I should be able to easily delete things. If there's not, I feel there should definitely be a documented workaround to opt out of this otherwise paid feature. Maybe this is a feature request.

All 24 comments

Cloud you try git lfs uninit?

Yes but how do I remove it for good?

Probably use git filter-branch to replace lfs pointers in your history with the actual data. There's no automated tool in LFS for this.

@technoweenie I feel like if I'm going to be ping'd via email to upgrade and purchase space if I tried the feature I should be able to easily delete things. If there's not, I feel there should definitely be a documented workaround to opt out of this otherwise paid feature. Maybe this is a feature request.

I would also like to know how to do this.

I ran git lfs uninstall, deleted the large file and .gitattributes file it created, and commited the changes but it still shows that I am using some storage.

How can I make my repo (internals and all) look like I never install git-lfs (I don't care about changing history)

OMG, I already ran: git lfs uninstall

And it said: C:\Users\hanr\GitHub\SGMPy [v0.1.1 = +7 ~1 -1 !]> git lfs uninstall Global Git LFS configuration has been removed. open C:\Users\hanr\GitHub\SGMPy\.git\hooks\pre-push: The system cannot find the file specified.

But I can still check the version.... C:\Users\hanr\GitHub\SGMPy [v0.1.1 = +7 ~1 -1 !]> git lfs ver git-lfs/1.2.0 (GitHub; windows amd64; go 1.6.1; git 9bd3b8e)

I also would like to know how to make my repo look like I never install git-lfs.

Thanks.

@alph486 The pay feature you are referring to is probably a specific server implementation, not a client detail (say like github.com's lfs server or bitbitbucket.org's lfs server, for example)

To answer the question, how to convert an local lfs repo into a non-lfs repo, I must first ask the question "What do you want to do about history?" Do you want all the previous versions to be converted, or only the most recent version?

FYI git lfs uninstall is not _really_ going to directly help here.

Convert tip only

If your only concern is the tip of the repo, you can probably remove the entries from .gitattributes and trigger the git index that every lfs file is different, and then add and commit those files. This is the same procedure in how you change the auto newlines in a git repo. I'll have to test this some, but this might get you in the right direction. The only caviate is you don't want to reset the .gitattributes files first. So I might....

  1. Modify .gitattribues and remove all the lfs settings
  2. Save
  3. git add
  4. git commit
  5. Then try the instructions in the link (I haven't tested this with lfs yet)

Convert all of history

In issue #326, we found a number of (WARNING SLOW) git filter-branch techniques that will ADD LFS files by rewriting history I imagine the same procedure used here can be used, only instead of git lfs track use git lfs untrack, and maybe if you are feeling a bit pedantic change the echo to say "Unadding" instead of "Adding"
Again, I haven't tested this yet, but I think it might work.

@andyneff
Thank you :smiley:

@Is it safe to remove .git/lfs after running 'git lfs uninstall' and following steps 1 through 9 in https://help.github.com/articles/remove-sensitive-data/ on all locations which ever used LFS? I still have considerable amount of data in that folder and I want it gone.

EDIT: Nevermind. git lfs prune was it.

@Aorjoa thank you! git lfs uninit worked well for me.

Hmm, I removed the files, did git lfs uninstall, deleted .gitattributes, did git lfs prune, pushed to the master, but it's still showing up in my billing as above quota. What gives?

but it's still showing up in my billing as above quota. What gives?

@nateGeorge Hey Nate, you ask a good question. If you need LFS files purged from your GitHub.com account to free up storage against your quota, please get in touch with GitHub Support and we'll be happy to help you.

Thanks donal, for anyone else viewing this, FYI:

If you want to purge specific files, you'll need to provide the Git LFS object ID values of each file. The object ID is a 64 character string which you can view by running the following command on the local clone of your repository:

git lfs ls-files --long

Or you can delete the entire repo.

Still, Amazon S3 is much cheaper ($1.3/month for 50GB vs $5/month for github, and that's after you exhaust the free tier, which is 5GB vs github's 1GB) and in my opinion easier to use.

[How to remove LFS completely in my repository]
[Undo git lfs migrate]
[git lfs untrack history]

I messed up my project's LFS setting (with git lfs migrate --everything) and try to restore files from LFS pointer in all commit history.

The goal fits the issue title, so i post my solution here in case any one need it.

BACKUP your repository before trying this script !

git filter-branch -f --prune-empty --tree-filter '
if [ -f .gitattributes ]; then 
    git rm -f .gitattributes
fi
find * -type f | while read FILE; do 
    while head -2 "$FILE" | grep -q "^oid sha256"; do
        ref=$(cat "$FILE")
        echo -n "$ref" | git lfs smudge > "$FILE"
        git add "$FILE"
    done
done' --tag-name-filter cat -- --all

@jcppkkk
Thanks for sharing the script, it is of great help to me.
But I kind of still have some traces of git-lfs remaining in my repo.

Namely, when I run
git lfs ls-files
, I still see a whole list of files.

Also, my
cat .git/config

still has lines:
[lfs "repo-path"]
locksverify=false

Any suggestions on how to remove these as well?

Haven't tried it yet, but I think that your purge-script should also have
git lfs untrack $FILE
inside the loop

and git lfs prune after it

I just removed .git folder and started over

I suggest the following:

$ git lfs uninstall

Now remove the .gitattributes

And proceed with the following steps for Dealing with line endings but skip step 6

Just want to reiterate this comment (https://github.com/git-lfs/git-lfs/issues/3026#issuecomment-457795501), which explains that git lfs uninstall && git rm .gitattributes _does not_ remove historical revisions of Git LFS objects in your history.

Regarding solutions - similar to the filter-branch way, you can use BFG.

java -jar "$BFG_PATH" --delete-files ".gitattributes" etc ... you may also want to do it for the actual LFS-tracked files (or just use --strip-blobs-bigger-than feature for that, may do the trick)

https://rtyley.github.io/bfg-repo-cleaner/

Regarding solutions - similar to the filter-branch way, you can use BFG.

Git LFS has a built-in tool that offers a similar feature set that support is offered for here, which is git lfs migrate export.

For me on mac os only sudo git lfs uninstall --system helped.

Easy way - download source zip, drop .gitattributes and start new repo

Here's the solution I ended up using: mirror-clone from original repo with LFS, export everything, mirror-push to a new non-LFS repo:

#!/bin/bash

remote_with_lfs=your_original_url               # your original repo, with LFS
remote_without_lfs=your_rewritten_url           # your new repo, rewritten without LFS; expected to be empty (just init'd), otherwise you need to force-push and risk a mess
git clone --mirror $remote_with_lfs migrated    # use --mirror or --bare, otherwise you'll need to track all branches before running export
cd migrated
git lfs migrate export --include="*" --everything
git push $remote_without_lfs --mirror           # pushes all branches AND tags: https://stackoverflow.com/a/49343086/322119

This will reinject all the large files' versions across the whole history.
This is exactly what I wanted, so I'm happy (I was afraid it was only gonna push new files at the head, losing history), but be warned that it rewrites history (which is why I'm pushing to a new, different repo).

I used git lfs pull to download original file then git lfs uninstall, after that I removed the .gitattributes file and commit again.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

panpan0000 picture panpan0000  路  3Comments

lacombar picture lacombar  路  3Comments

tarioch picture tarioch  路  4Comments

danielbayley picture danielbayley  路  4Comments

cukiakimani picture cukiakimani  路  3Comments