Skip to content

Instantly share code, notes, and snippets.

@Gnappuraz
Created September 6, 2017 20:15
Show Gist options
  • Select an option

  • Save Gnappuraz/aaeb897c16b3dfd748a0a158526af8e6 to your computer and use it in GitHub Desktop.

Select an option

Save Gnappuraz/aaeb897c16b3dfd748a0a158526af8e6 to your computer and use it in GitHub Desktop.
git remove old lfs files
git -c GIT_LFS_SKIP_SMUDGE=1 clone repo //clone a repo without downloading the files
// list all tracked files with git lfs (png, wav, mp3 especially)
// list for each file all the lfs versions
// run git filter on each file to point to the most recent one
git filter-branch --tree-filter 'sed -i "/old_pointer/new_pointer" filename' -- --all
// run a git lfs prune to remove the files not referenced anymore
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment