Skip to content

Instantly share code, notes, and snippets.

@sekimura
Last active August 29, 2015 14:02
Show Gist options
  • Save sekimura/ebf4c692523921a2ca4d to your computer and use it in GitHub Desktop.
Save sekimura/ebf4c692523921a2ca4d to your computer and use it in GitHub Desktop.
git-cleanarcpatch.bash
#/bin/bash
# git-cleanarcpatch
# -----------------
#
# Copyright 2014, Masayoshi Sekimura <sekimura@gmail.com>
# Licensed under the MIT license.
#
#
# How to Install:
#
# 1. Add this git-cleanarcpatch.bash to ~/bin/ or somewhere you have it in
# PATH env variable.
#
# 2. Add a new git alias config to your ~/.gitconfig file to run this bash
# script form a git command "git cleanarcpatch"
#
# [alias]
# cleanarcpatch = "!bash ~/bin/git-cleanarcpatch.bash"
#
BRANCHES=`git branch -v | grep arcpatch`
if [ ${#BRANCHES} -eq 0 ]; then
exit
fi
for branch in "$BRANCHES[@]"; do
echo "$branch"
done
read -p "Are you sure you want to delete those? (Y/n) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
for branch in "$BRANCHES[@]"; do
echo "$branch" | awk '{print "git branch -D " $1}' | bash -
done
else
echo
fi
@sekimura
Copy link
Author

actually you don't need this.

$ arc alias cleanup -- '!git branch | cut -c3- | grep arcpatch- | xargs -n1 git branch -D'

or define the alias in your arcconfig file

"aliases" : {                                                                                                                                                                   
    "cleanup" : ["!git branch | cut -c3- | grep arcpatch- | xargs -n1 git branch -D"]
}

https://secure.phabricator.com/T3277

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment