Skip to content

Instantly share code, notes, and snippets.

@jmatt
Forked from jhoblitt/convert-lfs.sh
Last active November 17, 2015 22:54
Show Gist options
  • Save jmatt/60900a6961cbdaecb362 to your computer and use it in GitHub Desktop.
Save jmatt/60900a6961cbdaecb362 to your computer and use it in GitHub Desktop.
This script was used to migrate from gitosis to https://github.com/lsst/afwdata
# converting an existing repo to use "lfs"
#
# note that a .gitattributes file for lfs needs to be added to any commit in
# which large files are present in the tree
wget http://repo1.maven.org/maven2/com/madgag/bfg/1.12.7/bfg-1.12.7.jar -O bfg-1.12.7.jar
git clone --mirror git://git.lsstcorp.org/LSST/DMS/testdata/afwdata.git afwdata
cd afwdata
java -jar ../bfg-1.12.7.jar --convert-to-git-lfs '*.{boost,dat,fits,gz}' --no-blob-protection
git reset --hard
# stolen from https://gist.github.com/larsxschneider/a31fb77c7e9a9c9b81da
#for FILE in .git/lfs/objects/*; do
# OBJ_ID=$(basename "$FILE")
# OBJ_DIR=".git/lfs/objects/${OBJ_ID:0:2}/${OBJ_ID:2:2}"
# mkdir -p "$OBJ_DIR"
# mv "$FILE" "$OBJ_DIR/$OBJ_ID"
#done
git filter-branch --tree-filter "echo '*.boost filter=lfs diff=lfs merge=lfs -text
*.dat filter=lfs diff=lfs merge=lfs -text
*.fits filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text' > .gitattributes" HEAD
git reflog expire --expire=now --all && git gc --prune=now
git lfs init
git remote rename origin upstream
git remote add origin https://github.com/lsst/afwdata.git
git push -u origin master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment