Last active
May 19, 2022 06:48
-
-
Save cansik/ad9bdc68d9513016e963f71f722d8a50 to your computer and use it in GitHub Desktop.
Revisions
-
cansik revised this gist
Jun 14, 2020 . 1 changed file with 5 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -16,7 +16,6 @@ FILESTXT="$REPODIR-lfs.txt" if [ -d "$REPODIR" ]; then rm -Rf "$REPODIR"; fi # clone git lfs uninstall git clone "$REPO" "$REPODIR" @@ -56,9 +55,13 @@ git reflog expire --expire=now --all && git gc --prune=now --aggressive # remove files from head and commit for LFSFILE in "${LSFFILES[@]}"; do FILENAME=`echo "$LFSFILE" | rev | cut -d '/' -f 1 | rev` # completely removes file git rm -f "*$FILENAME" # removes file from lfs an adds them to normal git # git rm --cached "*$FILENAME" # git add "*$FILENAME" done git commit -m "removed lfs files from repository" -
cansik revised this gist
Jun 14, 2020 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -59,6 +59,7 @@ for LFSFILE in "${LSFFILES[@]}"; do # maybe used --cached to not delete file locally FILENAME=`echo "$LFSFILE" | rev | cut -d '/' -f 1 | rev` git rm -f "*$FILENAME" # git add "*$FILENAME" done git commit -m "removed lfs files from repository" -
cansik revised this gist
Jun 14, 2020 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -20,8 +20,6 @@ if [ -d "$REPODIR" ]; then rm -Rf "$REPODIR"; fi git lfs uninstall git clone "$REPO" "$REPODIR" # list all files cd "$REPODIR" git lfs ls-files --all > "../$FILESTXT" @@ -75,4 +73,6 @@ read -p "Press enter to push changes!" git push --force # remove chunk rm -rf .git/lfs git lfs install exit -
cansik revised this gist
Jun 14, 2020 . 1 changed file with 16 additions and 11 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -41,16 +41,6 @@ done < "../$FILESTXT" # remove git lfs git rm .gitattributes # run bfg cleaner for each file LSFFILENAMES=() for LFSFILE in "${LSFFILES[@]}"; do @@ -66,8 +56,23 @@ bfg --delete-files "$LFSARGS" # reflog git reflog expire --expire=now --all && git gc --prune=now --aggressive # remove files from head and commit for LFSFILE in "${LSFFILES[@]}"; do # maybe used --cached to not delete file locally FILENAME=`echo "$LFSFILE" | rev | cut -d '/' -f 1 | rev` git rm -f "*$FILENAME" done git commit -m "removed lfs files from repository" echo "" echo "" echo "FINISHED! now run 'git push --force' to upload it to the server!" echo "After that install git lfs again: 'git lfs install'" echo "And remove git lfs-index from repo: 'rm -rf .git/lfs'" read -p "Press enter to push changes!" git push --force # remove chunk rm -rf .git/lfs -
cansik revised this gist
Jun 14, 2020 . 1 changed file with 19 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,12 @@ #/bin/zsh echo "converting lfs to normal git repo..." if [ $# -eq 0 ] then echo "Use: rm-lfs.sh [http-git-url]" exit fi REPO=$1 REPODIR=`echo "$REPO" | rev | cut -d '/' -f 1 | rev` @@ -12,8 +17,11 @@ if [ -d "$REPODIR" ]; then rm -Rf "$REPODIR"; fi # clone # export GIT_LFS_SKIP_SMUDGE=1 # without lfs git lfs uninstall git clone "$REPO" "$REPODIR" read -p "Press enter to continue" # list all files cd "$REPODIR" git lfs ls-files --all > "../$FILESTXT" @@ -24,26 +32,28 @@ while IFS= read -r line do # caution, sometimes it's an asterix, sometimes a dash! # https://stackoverflow.com/a/36585611/1138326 NORMLINE=`echo $line | sed 's/*/-/'` echo "$NORMLINE" LFSFILE=`echo "${NORMLINE#* - }"` LSFFILES+=( "$LFSFILE" ) done < "../$FILESTXT" # remove git lfs git rm .gitattributes # remove files from head and commit for LFSFILE in "${LSFFILES[@]}"; do # maybe used --cached to not delete file locally FILENAME=`echo "$LFSFILE" | rev | cut -d '/' -f 1 | rev` git rm -f "*$FILENAME" done git commit -m "removed lfs files from repository" read -p "Press enter to continue" # run bfg cleaner for each file LSFFILENAMES=() for LFSFILE in "${LSFFILES[@]}"; do FILENAME=`echo "$LFSFILE" | rev | cut -d '/' -f 1 | rev` LSFFILENAMES+=( "$FILENAME" ) done @@ -58,4 +68,6 @@ git reflog expire --expire=now --all && git gc --prune=now --aggressive echo "" echo "" echo "FINISHED! now run 'git push --force' to upload it to the server!" echo "After that install git lfs again: 'git lfs install'" echo "And remove git lfs-index from repo: 'rm -rf .git/lfs'" -
cansik revised this gist
Jun 14, 2020 . 1 changed file with 6 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,18 +10,20 @@ FILESTXT="$REPODIR-lfs.txt" # prepare if [ -d "$REPODIR" ]; then rm -Rf "$REPODIR"; fi # clone # export GIT_LFS_SKIP_SMUDGE=1 # without lfs git clone "$REPO" "$REPODIR" # list all files cd "$REPODIR" git lfs ls-files --all > "../$FILESTXT" # create lfs file index LSFFILES=() while IFS= read -r line do # caution, sometimes it's an asterix, sometimes a dash! # https://stackoverflow.com/a/36585611/1138326 LFSFILE=`echo "$line" | awk -F" - " '{print $2}'` LSFFILES+=( "$LFSFILE" ) done < "../$FILESTXT" @@ -56,7 +58,4 @@ git reflog expire --expire=now --all && git gc --prune=now --aggressive echo "" echo "" echo "FINISHED! now run 'git push --force' to upload it to the server!" -
cansik revised this gist
Jun 13, 2020 . No changes.There are no files selected for viewing
-
cansik revised this gist
Jun 13, 2020 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -35,7 +35,7 @@ for LFSFILE in ${LSFFILES[@]}; do # maybe used --cached to not delete file locally FILENAME=`echo "$LFSFILE" | rev | cut -d '/' -f 1 | rev` git rm -f "*$FILENAME" # git add "$LFSFILE" # use only when cached done git commit -m "removed lfs files from repository" @@ -51,7 +51,7 @@ LFSARGS="{"$(IFS=,; printf '%s' "${LSFFILENAMES[*]}")"}" echo $LFSARGS bfg --delete-files "$LFSARGS" # reflog git reflog expire --expire=now --all && git gc --prune=now --aggressive echo "" -
cansik created this gist
Jun 13, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,62 @@ #/bin/zsf echo "converting lfs to normal git repo..." REPO=$1 REPODIR=`echo "$REPO" | rev | cut -d '/' -f 1 | rev` FILESTXT="$REPODIR-lfs.txt" # prepare if [ -d "$REPODIR" ]; then rm -Rf "$REPODIR"; fi # clone without lfs export GIT_LFS_SKIP_SMUDGE=1 git clone "$REPO" "$REPODIR" # list all files cd "$REPODIR" git lfs ls-files --all > "../$FILESTXT". # create lfs file index LSFFILES=() while IFS= read -r line do LFSFILE=`echo "$line" | awk -F" - " '{print $2}'` LSFFILES+=( "$LFSFILE" ) done < "../$FILESTXT" # remove git lfs git lfs uninstall git rm .gitattributes # remove files from head and commit for LFSFILE in ${LSFFILES[@]}; do # maybe used --cached to not delete file locally FILENAME=`echo "$LFSFILE" | rev | cut -d '/' -f 1 | rev` git rm -f "*$FILENAME" git add "$LFSFILE" done git commit -m "removed lfs files from repository" # run bfg cleaner for each file LSFFILENAMES=() for LFSFILE in ${LSFFILES[@]}; do FILENAME=`echo "$LFSFILE" | rev | cut -d '/' -f 1 | rev` LSFFILENAMES+=( "$FILENAME" ) done echo "removing all files with a single command" LFSARGS="{"$(IFS=,; printf '%s' "${LSFFILENAMES[*]}")"}" echo $LFSARGS bfg --delete-files "$LFSARGS" # refolg git reflog expire --expire=now --all && git gc --prune=now --aggressive echo "" echo "" echo "FINISHED! now run 'git push' to upload it to the server!" git lfs push origin master --all git push --no-verify --force