Reputation: 2445
I'm playing around with my custom commands, and I'm currently trying to change a remote Git branch programatically using bash.
issue() {
if [ `git branch --list issue_$1` ]
then
git checkout issue_$1
else
git checkout -b issue_$1
git branch -u origin issue_${1}
fi
}
The idea is this function will try to find the branch issue_X, if it does it switches, otherwise it creates and sets the remote origin.
The problem is git branch -u origin issue_${1}
I don't know how to do this, and I'm having trouble googling for it because I don't know what this process is called.
Thanks a lot for the help!
Upvotes: 1
Views: 417
Reputation: 94422
I don't know how to do
git branch -u origin issue_${1}
If a remote-tracking branch origin/issue_${1}
exists you can do git branch -u origin/issue_${1}
.
The problem is that in your situation the remote-tracking branch doesn't exit and you have to create it:
git push -u origin issue_${1}
Upvotes: 1