Remove Git LFS

Services such as GitHub offer Git LFS for their repositories, but these may not exceed the additional storage of 1 GiB. Purchasing additional quotas from GitHub is then quite expensive.

But how do you get rid of Git LFS in such a repository?

The following steps allow you to get rid of Git LFS:

  1. Use git lfs ls-files to get a list of all files managed by Git LFS.

  2. Next, we make sure that we have checked out all large files with

    $ git lfs fetch --all
    $ git lfs checkout
    
  3. Remove the Git LFS filters:

    1. To do this, you must first remove entries such as :*.png filter=lfs diff=lfs merge=lfs -text from your .gitattributes file.

    2. You can then stop Git tracking for each deleted entry in the .gitattributes file, for example with git lfs untrack '*.png'.

      Alternatively, you can also use cut -f 1 < .gitattributes | xargs "git lfs untrack {}" for all files managed with Git LFS.

    3. Finally, the line ends should be normalised with git add --renormalize ..

  4. Now Git LFS can be uninstalled with git lfs uninstall.

  5. Finally, the changes must be transferred to the server.

Now you can switch to Manage data with DVC, for example, to manage large files in a versioned manner.