How to STOP using Git LFS in a repository
Asked Answered
W

1

13

I recently setup Git LFS in our primary repo and have had nothing be problems with it so far. On top of that, we only set it up to stop a ballooning effect on our separate build repo (which is going away in favor of a new process).

The primary problem at this point (among other issues) is that we are trying to start pushing builds from the primary repo to an Acquia repo (which is required for Acquia deployments). Acquia does not support Git LFS and I don't have time to fight with them on that nor argue the merits of the host solution (this is what we have and have had for awhile) with anyone that can affect such change.

I would like to just remove it and it seems that I have only partially removed it. It seems that online documentation for this is scant at best.

Here is what I have done:

  1. Run git lfs untrack *
  2. Then git lfs uninstall
  3. Finally I reverted my .gitattributes file to it's prior state

I pushed that up and locally it seems to have eliminated a lot of object tracking (by merit of me going into .git/lfs and rooting through the folder structure). Running git lfs ls-files does not show me anything at all.

However, when I pull it down on a separate clone it shows more than a thousand files still tracked by it when I try to push to Acquia and it fails because Acquia does not support it. Charming, I know.

I suspect that removing it entirely would eliminate the .git/lfs directory or at least the contents of it. If nothing else it should eliminate the tracking in the clones the pull down the changes. It does not.

I think that I may be missing a step to change the file pointers back to what they were, but I am unsure of what else I can safely do. I want to keep the files it tracked. My repo is hosted on Bitbucket cloud.

Waldman answered 11/12, 2017 at 23:40 Comment(1)
I am doing a ton of reading on this right now. So thinking out loud here. Because I made the changes in a single commit, is there any reason I could not just do a git revert to undo the commit that setup Git LFS in the first place? Would the reset the file pointers?Waldman
M
2

From GitHub, and is along the steps you have taken as well,

https://github.com/git-lfs/git-lfs/issues/3026

git lfs uninstall

This removes hooks and smudge/clean filter configuration and this is only the beginning, mua-ha-ha

How can we reindex/re-commit lfs'd files to restore them???

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. good thing i read just now that this must be done before the .gitattributes step

But how the heck do we do this? (sure don't want to accidentally change all my newlines, hah)

ok, there's some talk in this issue about a methodology

git lfs ls-files — view lfs files

for each file, use globs if you can:

git rm --cached myfile.psd — "remove" the lfs file
git add myfile.psd — add the "normal" file
git commit -m "restore files from lfs"

let me know if that makes sense

remove lfs .gitattribute entries

this will apparently prevent lfs from resurrecting itself

How do we remove remaining files, seen via git lfs ls-files??? I'm guessing we git lfs untrack them one-at-a-time

nope, untrack doesn't remove them... hmm... what does it do?

maybe once i figure out step 2, this'll be done

yep, step 2 knocks this one out

What do we tell our fellow contributors to do??? I'm guessing they just need to git lfs uninstall? Do they also need to git lfs untrack stored files or anything like that?

Also, i have no interest in rewriting git history here, that's silly... i just want to move forward with my collaborators once this is taken care of

Mikey answered 16/10, 2020 at 10:15 Comment(1)
@Shaqil instead of copying and pasting the entire GitHub comment please add only the relevant details so as to make the answer easy and quick to read...Hahnke

© 2022 - 2024 — McMap. All rights reserved.