If
- I have local repo with a remote
$REMOTE
already set up - and a new branch
$BRANCH
exists on the remote repo that I haven't fetched, yet
can I fetch that branch and check it out into a tracking local branch of the same name in a single command?
I can achieve the desired result in two commands either with
git fetch $REMOTE $BRANCH
git checkout $BRANCH # or more explicitly git checkout -b $BRANCH $REMOTE/$BRANCH
or (inspired by this answer to Question How do I check out a remote Git branch?) with
git fetch $REMOTE $BRANCH:$BRANCH
git branch --set-upstream-to=$BRANCH $BRANCH