code: def override_root_main_ref(config, remotes, banner):
      
      log = logging.getLogger(__name__)
      greatest_tag = config.banner_greatest_tag if banner else config.greatest_tag
      recent_tag = config.banner_recent_tag if banner else config.recent_tag
  
      if greatest_tag or recent_tag:
          candidates = [r for r in remotes if r['kind'] == 'tags']
          if candidates:
              multi_sort(candidates, ['semver' if greatest_tag else 'time'])
              config.update({'banner_main_ref' if banner else 'root_ref': candidates[0]['name']}, overwrite=True)
          else:
              flag = '--banner-main-ref' if banner else '--root-ref'
              log.warning('No git tags with docs found in remote. Falling back to %s value.', flag)
  
      ref = config.banner_main_ref if banner else config.root_ref
      return ref in [r['name'] for r in remotes]
docs: Override root_ref or banner_main_ref with tags in config if user requested.
  
      :param sphinxcontrib.versioning.lib.Config config: Runtime configuration.
      :param iter remotes: List of dicts from Versions.remotes.
      :param bool banner: Evaluate banner main ref instead of root ref.
  
      :return: If root/main ref exists.
      :rtype: bool