From fdbc3d21510afa889f9f71a66fcc6f554b159a69 Mon Sep 17 00:00:00 2001 From: Matheus Albino Brunhara Date: Thu, 4 Apr 2024 13:31:20 -0300 Subject: [PATCH] Add git-cat-file-for-each-branch.sh and git-lfs-undo.sh in scripts/shell/job --- .../shell/job/git-cat-file-for-each-branch.sh | 17 ++++++++++ scripts/shell/job/git-lfs-undo.sh | 34 +++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100755 scripts/shell/job/git-cat-file-for-each-branch.sh create mode 100755 scripts/shell/job/git-lfs-undo.sh diff --git a/scripts/shell/job/git-cat-file-for-each-branch.sh b/scripts/shell/job/git-cat-file-for-each-branch.sh new file mode 100755 index 0000000..535db56 --- /dev/null +++ b/scripts/shell/job/git-cat-file-for-each-branch.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +filename=$1 +repo_dir=`pwd` + +for branch in $(git for-each-ref --format='%(refname)' refs/remotes/origin); do + cmd_out=`git show $branch:$filename` + + if [ $? -ne 0 ]; then + cmd_out="[$branch] O arquivo \"$filename\" não existe no branch" + else + echo "[$branch] Arquivo:" + echo "$cmd_out" + fi + + printf "\n" +done diff --git a/scripts/shell/job/git-lfs-undo.sh b/scripts/shell/job/git-lfs-undo.sh new file mode 100755 index 0000000..a32f3b8 --- /dev/null +++ b/scripts/shell/job/git-lfs-undo.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +repo_dir=`pwd` +cd $repo_dir + +# method 1 +# source: https://github.com/git-lfs/git-lfs/issues/3026 + +# lfs_files=`git lfs ls-files | awk -F' ' {'print $3'}` + +# for f in ${lfs_files[@]}; do +# git rm --cached $f # "remove" the lfs file +# git add $f # add the "normal" file +# done + +# gitattr_filename='.gitattributes' +# if [ -f "$gitattr_filename" ]; then +# rm --force $gitattr_filename +# git add $gitattr_filename +# fi + +# git commit -m "restore files from lfs" + +# method 2 +# source: https://stackoverflow.com/questions/35011366/move-git-lfs-tracked-files-under-regular-git/54119191#54119191 + +# git lfs untrack "*" +# git add --renormalize . +# git commit -m "Restore file contents that were previously in LFS" + +# method 3 +# source: https://gist.github.com/everttrollip/198ed9a09bba45d2663ccac99e662201?permalink_comment_id=3695821#gistcomment-3695821 + +git-lfs uninstall --local && echo " " > .gitattributes && git add --renormalize .