Skip to content

Instantly share code, notes, and snippets.

@bartman
Created December 12, 2012 19:15
Show Gist options
  • Save bartman/4270666 to your computer and use it in GitHub Desktop.
Save bartman/4270666 to your computer and use it in GitHub Desktop.
git new-feature <branch> [ <remote> ]
[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