Skip to content

Instantly share code, notes, and snippets.

@StanislawAntol
Last active October 19, 2017 23:45
Show Gist options
  • Save StanislawAntol/9187bfcb699182334d0d752c11e6efa9 to your computer and use it in GitHub Desktop.
Save StanislawAntol/9187bfcb699182334d0d752c11e6efa9 to your computer and use it in GitHub Desktop.
git version 2.14.2
git-lfs/2.3.4 (GitHub; linux amd64; go 1.8.1)
git version 2.14.2
LocalWorkingDir=
LocalGitDir=
LocalGitStorageDir=
LocalMediaDir=
LocalReferenceDir=
TempDir=/tmp/git-lfs
ConcurrentTransfers=3
TusTransfers=false
BasicTransfersOnly=false
SkipDownloadErrors=false
FetchRecentAlways=false
FetchRecentRefsDays=7
FetchRecentCommitsDays=0
FetchRecentRefsIncludeRemotes=true
PruneOffsetDays=3
PruneVerifyRemoteAlways=false
PruneRemoteName=origin
LfsStorageDir=lfs
AccessDownload=none
AccessUpload=none
DownloadTransfers=basic
UploadTransfers=basic
git config filter.lfs.process = "git-lfs filter-process"
git config filter.lfs.smudge = "git-lfs smudge -- %f"
git config filter.lfs.clean = "git-lfs clean -- %f"
================================ dir/file.bin ================================
Initialized empty Git repository in /home/s.antol/tmp/repo/.git/
1024+0 records in
1024+0 records out
1024 bytes (1.0 kB, 1.0 KiB) copied, 0.00402567 s, 254 kB/s
[master (root-commit) 63cc097] Size 1024
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 dir/file.bin
2048+0 records in
2048+0 records out
2048 bytes (2.0 kB, 2.0 KiB) copied, 0.00777142 s, 264 kB/s
[master 9ab1531] Size 2048
1 file changed, 0 insertions(+), 0 deletions(-)
rewrite dir/file.bin (100%)
+++++ git log before migration+++++
commit 9ab153169c291b5f3fc4cba9a05094f1d6d5457f (HEAD -> master, tag: v2048)
Author: Stanislaw Antol
Date: Thu Oct 19 16:44:23 2017 -0700
Size 2048
commit 63cc097cf2e1e15c9a227278ad61f1b0481552af (tag: v1024)
Author: Stanislaw Antol
Date: Thu Oct 19 16:44:23 2017 -0700
Size 1024
master,v1024,v2048
migrate: Sorting commits: ..., done
migrate: Rewriting commits: 100% (2/2), done
master 9ab153169c291b5f3fc4cba9a05094f1d6d5457f -> 0540bba362a01679fd3a1926839d3187f04a8894
migrate: Updating refs: ..., done
migrate: checkout: ..., done
+++++ git lfs ls-files +++++
500c105375 - dir/file.bin
+++++ git lfs status +++++
On branch master
Git LFS objects to be committed:
Git LFS objects not staged for commit:
+++++ git log after migration+++++
commit 0540bba362a01679fd3a1926839d3187f04a8894 (HEAD -> master)
Author: Stanislaw Antol
Date: Thu Oct 19 16:44:23 2017 -0700
Size 2048
commit 5c9d0e8d842af31f994279ae3f29d67906139adb
Author: Stanislaw Antol
Date: Thu Oct 19 16:44:23 2017 -0700
Size 1024
+++++ git show-ref --dereference --tags +++++
2869faf152d0be176ce5d95f4f25ea98c439149c refs/tags/v1024
63cc097cf2e1e15c9a227278ad61f1b0481552af refs/tags/v1024^{}
fae9f9cbe373e0636e93640d53977dde2c3296b9 refs/tags/v2048
9ab153169c291b5f3fc4cba9a05094f1d6d5457f refs/tags/v2048^{}
git --version
git lfs env
GIT_TRACE=1
REPO_DIR=${HOME}/tmp/repo
EXT=bin
start_dir=`pwd`
DIRS=("dir/")
for DIR in "${DIRS[@]}";
do
FILENAME=${DIR}file.${EXT}
echo "================================ ${FILENAME} ================================"
rm -rf ${REPO_DIR}
mkdir -p ${REPO_DIR}
cd ${REPO_DIR}
git init
# # git LFS works fine if initially tracking
# git lfs track *.${EXT}
mkdir -p ${REPO_DIR}/${DIR}
refs="master"
for size in 1024 2048
do
dd if=/dev/urandom of=${FILENAME} bs=1 count=${size}
git add ${FILENAME}
git commit -m "Size ${size}"
git tag -a "v${size}" -m "Size of ${size}"
refs="${refs},v${size}"
done
echo -e "\n+++++ git log before migration+++++"
git log
# None of the below commands work for the case where the file is in a directory
#git lfs migrate import --include=${FILENAME} --include-ref=master
#git lfs migrate import --include=**/*.${EXT} --include-ref=master
#git lfs migrate import --include=*.${EXT} --everything
echo ${refs}
git lfs migrate import --include=*.${EXT} --include-ref="${refs}"
echo -e "\n+++++ git lfs ls-files +++++"
git lfs ls-files
echo -e "\n+++++ git lfs status +++++"
git lfs status
echo -e "\n+++++ git log after migration+++++"
git log
done
echo -e "\n+++++ git show-ref --dereference --tags +++++"
git show-ref --dereference --tags
cd ${start_dir}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment