Trying to migrate a repo (including history) OUT of Git LFS.
I ran git lfs migrate export --include="*" --everything
(mentioned here) on a test repo, but it didn't work as expected and left LFS pointer files instead of converting them all to objects.
I tried alternative methods, following this. Unfortunately it still left pointer files, so I combined it with this.
In the end, I even ran all the commands together:
git lfs uninstall
git filter-branch -f --prune-empty --tree-filter '
git lfs fetch
git lfs checkout
git lfs ls-files | cut -d " " -f 3 | xargs touch
git lfs ls-files | cut -d " " -f 3 | xargs git rm --cached
git rm -f .gitattributes
git lfs ls-files | cut -d " " -f 3 | xargs git add --force
git add --renormalize .
' --tag-name-filter cat -- --all
Didn't work. Gave me the following error for multiple files, and the filtered commits have pointer files instead of the objects.
Errors logged to <PATH>
Use `git lfs logs last` to view the log.
Rewrite <COMMIT SHA ####> (2/9) (2 seconds passed, remaining 7 predicted)
Checking out LFS objects: 0% (0/1), 0 B | 0 B/s
Checking out LFS objects: 100% (2/2), 3.1 KB | 0 B/s, done
Error updating the git index:
error: picture.png: cannot add to the index - missing --add option?
fatal: Unable to process path picture.png
I tried running the same commands on only the tip commit, and it seems like touch
, rm --cached
, add --renormalize .
, add --force
don't show any modifications with git status
. So I'm unable to re-add the cleaned/pulled object files to a new commit.
Maybe that's the problem? So how to forcibly re-add unchanged file to index when using filter-branch?
(Using Windows with git bash.)
Do a git lfs migrate export --everything --include .
to replace all the LFS pointers by the real files in the git history. For more details, see http://stackoverflow.com/a/57681990/717372
Run git lfs uninstall
to remove lfs hooks.
And verify that the .gitattributes
has the lfs filters removed.
If the lfs filters were not removed, and if .gitattributes
was only needed for LFS, delete the file in all of history with:
git filter-branch -f --prune-empty --tree-filter '
git rm -f .gitattributes --ignore-unmatch
' --tag-name-filter cat -- --all
Otherwise if .gitattributes
has non-LFS lines, remove only the LFS filters by replacing the above tree-filter command with git lfs untrack
(reference here and here).