Created
December 14, 2018 10:34
-
-
Save octavian-nita/13b7eedde5d334090e0ae3188ad03e89 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Consider writing robust bash shell scripts ( http://mywiki.wooledge.org/ ;) | |
set -o nounset | |
# ---------------------- | |
# Command line arguments | |
# ---------------------- | |
declare B_OLD_NAME= | |
declare B_NEW_NAME= | |
case $# in | |
1) | |
B_OLD_NAME=`git rev-parse --abbrev-ref HEAD` | |
B_NEW_NAME="$1" | |
;; | |
2) | |
B_OLD_NAME="$1" | |
B_NEW_NAME="$2" | |
;; | |
*) | |
printf "\nusage:\n\t`basename ${BASH_SOURCE}` [<old-name>] <new-name>\n" 1>&2 | |
return 1 | |
esac | |
# ---- | |
# Main | |
# ---- | |
printf "\nRenaming branch ${B_OLD_NAME} to ${B_NEW_NAME}...\n" | |
git branch -m ${B_OLD_NAME} ${B_NEW_NAME} \ | |
&& git push origin :${B_OLD_NAME} ${B_NEW_NAME} \ | |
&& git push origin -u ${B_NEW_NAME} | |
printf "\nDone.\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment