Skip to content

Instantly share code, notes, and snippets.

@Glutexo
Last active August 29, 2015 14:14
Show Gist options
  • Save Glutexo/98a962688bf925b7fd9e to your computer and use it in GitHub Desktop.
Save Glutexo/98a962688bf925b7fd9e to your computer and use it in GitHub Desktop.
GIT: Remove # from the end of the name of all branches that end with it.
#!/bin/sh
if [ $1 = "-f" ]
then
FORCE="$1"
TRAILING_PATTERN="$2"
else
FORCE=""
TRAILING_PATTERN="$1"
fi
git branch | grep "$TRAILING_PATTERN$" | sed -E "s/^[* ]+ ((.+)$TRAILING_PATTERN)$/\1 \2/g" | xargs -L1 git branch -m "$FORCE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment