Created
August 5, 2011 11:11
-
-
Save yuroyoro/1127324 to your computer and use it in GitHub Desktop.
git back でひとつ前に居たbranchに戻る
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/sh | |
# usage: | |
# git back でひとつ前に居たbranchに戻る | |
# git back N でN個前に戻る | |
# git back --listで履歴だす | |
# | |
# /usr/local/libexec/git-coreに置いてchmod +xしとけ | |
CNT=1 | |
if [ $# -ne 0 ]; then | |
if [ $1 = "--list" ]; then | |
git reflog | grep checkout | head -10 | cut -d' ' -f6 | |
exit | |
else | |
CNT=$1 | |
fi | |
fi | |
PREVIOUS_BRANCH=`git reflog | grep checkout | head -${CNT} | tail -1 | cut -d' ' -f6` | |
git checkout ${PREVIOUS_BRANCH} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment