Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reset git lfs repository to pointers

Tags:

git

git-lfs

I have a git lfs repository checked out. All the binaries are pointers. I pulled the real binaries with git lfs pull --include some/binaries.

I used the binaries and now I would like to "unpull" the binaries and convert them to the pointers again, so I can reclaim the disk space.

I didn't find any suitable command to do that, and mangling with .git/lfs/objects plus hard resets make me nervous.

Question: How to convert the tracked binaries back to pointers?

Edit:

  • I just found an open feature request for that: "Add command to undo fetch and checkout"
like image 362
Jakub M. Avatar asked Apr 12 '17 19:04

Jakub M.


1 Answers

An open LFS issue suggested to run

git read-tree HEAD && GIT_LFS_SKIP_SMUDGE=1 git checkout -f HEAD

Note:

If you run that in a dirty working tree, you'll blow away your changes, so don't do that.

source

This worked for me, unlike the script in the top answer. (maybe because I am using lfs inside a git submodule)

like image 98
David Liao Avatar answered Sep 19 '22 09:09

David Liao