I'm HOPING there is a better way to do this... BUT after redacted units of time, I found a way where you will NOT lose any history of existing large files. It is probably SLOW but it works.
I have run into a similar situation myself, but in my case, all my large files were sitting in submodules. So I was able to remove the submodules, track files, and add them back (without the submodules, HORRAY!) This way I can say I did maintain all my history, only some of the history is in the submodules. I'm guessing this is not similar to your situation, and that everything is in one big repo.
git filter-branch --prune-empty --tree-filter '
git config -f .gitconfig lfs.url "http://127.0.0.1:8080/user/repo"
git lfs track "*.npy"
git add .gitattributes .gitconfig
for file in $(git ls-files | xargs git check-attr filter | grep "filter: lfs" | sed -r "s/(.*): filter: lfs/\1/"); do
echo "Processing ${file}"
git rm -f --cached ${file}
echo "Adding $file lfs style"
git add ${file}
done' --tag-name-filter cat -- --all
git config lines are so that if you have an lfs server in a separate location than the git repo, everything works. IF you have them at the same url, you can skip that stepgit push -f origin master
(Optional) Collect garbage to shrink currently checked out repo
rm .git/refs/original -rf
git -c gc.reflogExpireUnreachable=0 -c gc.pruneExpire=now gc
(Optional) Collect garbage on a bare repo (on the remotes)
git -c gc.reflogExpireUnreachable=0 -c gc.pruneExpire=now gc
I hope this helps!
Untested ideas
Instead Step 1, just add
git lfs track "*.foo"
git config -f .gitconfig lfs.url "http://127.0.0.1:8080/user/repo"
git add .gitattributes .gitconfig
inside the for loop on step two. It should save that wasted initial rebase, and prevent the need for the git add .
Tested using git-lfs 0.5.1 and git 1.9.4.msysgit.1 (Yes, on windows 64 bit)