Fix error about switching branches on initial checkout

The --short option to symbolic-ref doesn't seem to be present in some versions
of git, so work around it.