Skip to content

Instantly share code, notes, and snippets.

@hamuhamu
Last active October 27, 2015 15:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hamuhamu/973f72103313b976c4da to your computer and use it in GitHub Desktop.
Save hamuhamu/973f72103313b976c4da to your computer and use it in GitHub Desktop.
Gitのカレントブランチをリネームするサブコマンド
#!/bin/bash
CURRENT_BRANCH_NAME=`git rev-parse --abbrev-ref HEAD`
NEW_BRANCH_NAME=$1
# 引数が空であればUsageを表示
if [ -z "$NEW_BRANCH_NAME" ]; then
echo 'You can rename a branch of git'
echo # 改行
echo 'Usage: git rename <CURRENT_BRANCH_NAME> <NEW_BRANCH_NAME>'
exit 1
fi
git branch -m $CURRENT_BRANCH_NAME $NEW_BRANCH_NAME
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment