Skip to content

Instantly share code, notes, and snippets.

@jamiegs
jamiegs / github-aliases.md
Last active April 2, 2024 18:04
My Github aliases for 1 command add commit push, and to cleanup merged branches.

Command aliases

   acp                     !f() { git add -A && git commit -m "$@" && git push --set-upstream origin $(git symbolic-ref --short HEAD); }; f
   cleanup                 !COMMAND="git branch -D"; while [[ $# -gt 0 ]]; do case "$1" in -d|--dryrun) COMMAND="echo"; shift; ;; *) MAIN_BRANCH="$1"; shift;; esac; done; MAIN_BRANCH="${MAIN_BRANCH:-$(git symbolic-ref refs/remotes/origin/HEAD)}"; git for-each-ref --merged="$MAIN_BRANCH" --no-contains="$MAIN_BRANCH" --format="%(refname:short)" refs/heads/ | xargs -n1 -r $COMMAND;#