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!
elsebranch to create a new branch, and mark it as tracking an upstream branch of the same name, and you don't know how to do the latter? Just push it.-ushould be the upstream branch name. My feeling is that a commandgit branch -u origin/issue_$1 issue_$1would be more appropriate. I suggest you remove all tags except git from your posting, as this question doesn't seem to be related to shell scripting, but to the naming of upstream branches.