Last active
August 29, 2015 14:04
-
-
Save s-aska/e1c74bc3b6d6770b1ce8 to your computer and use it in GitHub Desktop.
簡易に git merge する奴
This file contains 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
#!/bin/bash | |
# Usage: git-merge.sh [branch] | |
# ex: git-merge.sh master | |
set -ue | |
# set -e ... 途中でエラーが発生したら止める | |
# set -u ... 未定義の変数を参照したらエラー | |
if [[ $# == 0 ]]; | |
then | |
echo "Usage: git-merge.sh [branch]" | |
echo " ex: git-merge.sh master" | |
exit 1 | |
fi | |
TO="$1" | |
FROM=`git rev-parse --abbrev-ref HEAD` | |
function confirm() { | |
read -p "$@? [y/n] " y | |
if [ ! "x$y" = "xy" ]; | |
then | |
echo "Not Confirmed." | |
exit 1 | |
fi | |
return 0 | |
} | |
function echo_and_exec() { | |
echo | |
echo "> $@" | |
$@ | |
} | |
confirm "git merge $FROM => $TO" | |
echo_and_exec git checkout $TO | |
echo_and_exec git pull | |
echo_and_exec git merge $FROM | |
echo | |
confirm "git push origin $TO" | |
echo_and_exec git push origin $TO | |
echo_and_exec git checkout $FROM |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment