Created
December 12, 2012 19:15
-
-
Save bartman/4270666 to your computer and use it in GitHub Desktop.
git new-feature <branch> [ <remote> ]
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
[alias] | |
# create a new feature branch on the same remote as current branch | |
new-feature = "!f() { local feature=$1 remote=$2 base=$3 ; \ | |
if [[ -z $feature ]] ; then \ | |
echo >&2 \"git new-feature <branch> [ <remote> ] \" ; \ | |
return 1 ; \ | |
fi ; \ | |
if [[ -z $remote ]] ; then \ | |
local cur=$( git rev-parse --revs-only --symbolic-full-name HEAD ) ; \ | |
cur=${cur#refs/heads/} ; \ | |
if [[ -z \"$cur\" || HEAD = $cur ]] ; then \ | |
echo >&2 \"current branch unknown\" ; \ | |
return 1 ; \ | |
fi ; \ | |
remote=$( git config branch.$cur.remote ) ; \ | |
fi ; \ | |
echo >&2 \"Creating feature branch '$feature' for remote '$remote'\" ; \ | |
set -x ; \ | |
git push \"$remote\" \"HEAD:$feature\" ; \ | |
git checkout -t \"$remote/$feature\" ; \ | |
} ; f" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment