Skip to content

Instantly share code, notes, and snippets.

@olix0r
Created November 10, 2015 19:09
Show Gist options
  • Save olix0r/d470cf109bc1bd0db46d to your computer and use it in GitHub Desktop.
Save olix0r/d470cf109bc1bd0db46d to your computer and use it in GitHub Desktop.
a little script for reaping a merged working branch
#!/bin/sh
set -e
# When the current branch has been merged to the origin, update master
# and delete the local branch.
branch=$(git rev-parse --abbrev-ref HEAD)
if [ -z "$branch" ]; then
echo "Could not parse branch" >&2
exit 1
elif [ "$branch" = "master" ]; then
echo "Already on master" >&2
exit 2
else
echo ":; :; git co master"
git co master
echo ":; :; git pull origin master"
git pull origin master
echo ":; :; git branch -d $branch"
git branch -d "$branch"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment