Skip to content

Instantly share code, notes, and snippets.

@jamiegs
Last active April 2, 2024 18:04
Show Gist options
  • Save jamiegs/07278d88a1e66a54331069713f57d249 to your computer and use it in GitHub Desktop.
Save jamiegs/07278d88a1e66a54331069713f57d249 to your computer and use it in GitHub Desktop.
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;#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment