Skip to content

Instantly share code, notes, and snippets.

View JeffBelback's full-sized avatar

Jeff Belback JeffBelback

  • Cruise
  • Pittsburgh, PA
View GitHub Profile
@JeffBelback
JeffBelback / delete-old-branches.sh
Last active December 27, 2021 21:47
Git helper functions
#!/bin/bash
# Deletes branches that have been removed on origin
function no_remote() {
if git rev-parse --git-dir >/dev/null 2>&1; then
git fetch --prune
echo "Branches with no remote:"
git branch -vv | cut -c 3- | awk '$3 !~/\[/ { printf " %s\n", $1 }'
echo -e "\nDeleting branches with deleted remote:"
del=$(git branch -vv | awk '$4 ~/gone\]/ { printf "git branch -D %s && ", $1 }')
@JeffBelback
JeffBelback / diff-branch.sh
Last active February 4, 2021 09:10
Git Functions
function diff-branch() {
if [ -z $1 ]; then
echo please provide an branch
read WORKBRANCH
else
WORKBRANCH=$1
fi
if [ -z $2 ]; then
STABLEBRANCH='master'
@JeffBelback
JeffBelback / docker-destroy-all.sh
Last active May 25, 2024 20:19
Destroy all Docker Containers and Images
#!/bin/bash
# Stop all containers
containers=`docker ps -a -q`
if [ -n "$containers" ] ; then
docker stop $containers
fi
# Delete all containers
containers=`docker ps -a -q`
if [ -n "$containers" ]; then
docker rm -f -v $containers