code: def checkout_with_fetch(git_folder, refspec, repository="origin"):
      
      _LOGGER.info("Trying to fetch and checkout %s", refspec)
      repo = Repo(str(git_folder))
      repo.git.fetch(repository, refspec)  # FETCH_HEAD should be set
      repo.git.checkout("FETCH_HEAD")
      _LOGGER.info("Fetch and checkout success for %s", refspec)
docs: Fetch the refspec, and checkout FETCH_HEAD.
      Beware that you will ne in detached head mode.