Add git-cat-file-for-each-branch.sh and git-lfs-undo.sh in scripts/shell/job

This commit is contained in:
Matheus Albino Brunhara
2024-04-04 13:31:20 -03:00
parent 713fffee96
commit fdbc3d2151
2 changed files with 51 additions and 0 deletions

View File

@@ -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

View File

@@ -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 .