Check whether origin/remote branch exists before referencing it.

The check if the branch is pushed was throwing errors without it if
origin/remote didn't exist.