code: def query_remote_ref(self, remote, ref):
          
          out = self.log_call(['git', 'ls-remote', remote, ref],
                              cwd=self.cwd,
                              callwith=subprocess.check_output).strip()
          for sha, fullref in (l.split() for l in out.splitlines()):
              if fullref == 'refs/heads/' + ref:
                  return 'branch', sha
              elif fullref == 'refs/tags/' + ref:
                  return 'tag', sha
              elif fullref == ref and ref == 'HEAD':
                  return 'HEAD', sha
          return None, ref
docs: Query remote repo about given ref.
          :return: ``('tag', sha)`` if ref is a tag in remote
                   ``('branch', sha)`` if ref is branch (aka "head") in remote
                   ``(None, ref)`` if ref does not exist in remote. This happens
                   notably if ref if a commit sha (they can't be queried)