You should use a function as follow :
function gnb {
git checkout -b $1 && git push -u origin $1
}
Frage
I try to create a git alias in oh-my-zsh to create and push a new branch in one row:
alias gnb='git checkout -b $@ && git push -u origin $@'
If I type
gnb foo
I have this error :
error: switch `b' requires a value
If I split this alias in 2:
alias gnb='git checkout -b $@'
alias gpb 'git push -u origin $@'
And call them, everything works fine.
What am I doing wrong?
Lösung
You should use a function as follow :
function gnb {
git checkout -b $1 && git push -u origin $1
}