-
-
Save ignatiusreza/0fa82a586c2f96abb565ee0053e3986b to your computer and use it in GitHub Desktop.
custom git alias and script
This file contains 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 characters
Various custom bash & git "function" |
This file contains 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 characters
#!/bin/bash | |
docker ps -a -q -f status=exited | xargs -r docker rm -v 2> /dev/null | |
docker images -f "dangling=true" -q | xargs -r docker rmi 2> /dev/null | |
docker volume ls -qf dangling=true | xargs -r docker volume rm 2> /dev/null | |
docker secret ls -q | xargs -r docker secret rm 2> /dev/null |
This file contains 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 characters
#!/bin/bash | |
docker ps -a -q | xargs -r docker rm -v 2> /dev/null | |
docker images -q | xargs -r docker rmi 2> /dev/null | |
docker volume ls -q | xargs -r docker volume rm 2> /dev/null | |
docker secret ls -q | xargs -r docker secret rm 2> /dev/null | |
docker system prune --force --volumes |
This file contains 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 characters
git log --all -M -C --name-only --format='format:' "$@" \ | |
| sort \ | |
| grep -v '^$' \ | |
| uniq -c \ | |
| sort -n \ | |
| awk 'BEGIN {print "count\tfile"} {print $1 "\t" $2}' |
This file contains 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 characters
#!/bin/bash | |
if [[ $(git ls-remote origin develop | wc -l) == 1 ]]; then | |
echo "develop" | |
else | |
git main-branch | |
fi |
This file contains 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 characters
#!/bin/bash | |
# Yo Dawg, I heard you like git | |
git "$@" |
This file contains 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 characters
#!/bin/bash | |
# cleanup local git branches: remove merged branches and branches with missing remotes | |
set -e | |
git fetch -p | |
default=$(git default-branch) | |
main=$(git main-branch) | |
if branches=$(git branch --merged | grep -v '*' | grep -v $default | grep -v $main | grep -v "features/"); then | |
echo $branches | xargs git branch -d | |
else | |
echo Merged branches not found | |
fi | |
if branches=$(git branch -vv | grep -v '^*' | awk '/: gone]/{print $1}' | grep .); then | |
echo $branches | xargs git branch -D | |
else | |
echo No branches with missing remotes | |
fi |
This file contains 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 characters
#!/bin/bash | |
if [[ $(git ls-remote origin main | wc -l) == 1 ]]; then | |
echo "main" | |
else | |
echo "master" | |
fi |
This file contains 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 characters
#!/bin/bash | |
# pull latest remote and prune both remote and local branches | |
set -e | |
git refresh | |
git remote prune origin | |
git localprune |
This file contains 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 characters
#!/bin/bash | |
# pull latest remote either from upsteam or origin | |
# update origin if upstream is found | |
set -e | |
default=$(git default-branch) | |
git checkout $default | |
if [[ git ls-remote --quiet --exit-code upstream 2> /dev/null ]] then | |
git fetch upstream $default | |
git merge upstream/$default | |
git push origin $default | |
else | |
git pull | |
fi |
This file contains 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 characters
#!/bin/bash | |
# pull latest version of certain branch from remote, discarding local changes and resolving conflict | |
set -e | |
default=$(git default-branch) | |
main=$(git main-branch) | |
if branch=$(git rev-parse --abbrev-ref HEAD 2> /dev/null); then | |
if [[ "$branch" == "HEAD" ]]; then | |
echo In a detached head && exit 1 | |
elif [[ "$branch" == "$default" ]]; then | |
echo In $default branch && exit 1 | |
elif [[ "$branch" == "$main" ]]; then | |
echo In $main branch && exit 1 | |
else | |
git checkout $default | |
git pull | |
git branch -D $branch | |
git checkout $branch | |
git status | |
fi | |
else | |
echo Unable to get current branch && exit 1 | |
fi |
This file contains 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 characters
#!/bin/bash | |
find -name 'node_modules' -exec rm -rf {} + |
This file contains 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 characters
#!/bin/bash | |
set -e | |
skadoosh-node-modules | |
yarn | |
yarn check |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment