class_docstr: Temp directory experiment executor.
class_docstr_tok: ["Temp","directory","experiment","executor","."]
code: def init_git(
      self,
      repo: "Repo",
      scm: "Git",
      stash_rev: str,
      entry: "ExpStashEntry",
      infofile: Optional[str],
      branch: Optional[str] = None,
  ):
      from dulwich.repo import Repo as DulwichRepo
  
      from dvc.repo.experiments.utils import push_refspec
  
      DulwichRepo.init(os.fspath(self.root_dir))
  
      self.status = TaskStatus.PREPARING
      if infofile:
          self.info.dump_json(infofile)
  
      temp_head = f"{TEMP_NAMESPACE}/head-{uuid()}"
      temp_merge = f"{TEMP_NAMESPACE}/merge-{uuid()}"
      temp_baseline = f"{TEMP_NAMESPACE}/baseline-{uuid()}"
  
      temp_ref_dict = {
          temp_head: entry.head_rev,
          temp_merge: stash_rev,
          temp_baseline: entry.baseline_rev,
      }
      with get_exp_rwlock(
          repo, writes=[temp_head, temp_merge, temp_baseline]
      ), self.set_temp_refs(scm, temp_ref_dict):
          # Executor will be initialized with an empty git repo that
          # we populate by pushing:
          #   EXEC_HEAD - the base commit for this experiment
          #   EXEC_MERGE - the unmerged changes (from our stash)
          #       to be reproduced
          #   EXEC_BASELINE - the baseline commit for this experiment
          refspec = [
              (temp_head, EXEC_HEAD),
              (temp_merge, EXEC_MERGE),
              (temp_baseline, EXEC_BASELINE),
          ]
  
          if branch:
              refspec.append((branch, branch))
              with get_exp_rwlock(repo, reads=[branch]):
                  push_refspec(scm, self.git_url, refspec)
              self.scm.set_ref(EXEC_BRANCH, branch, symbolic=True)
          else:
              push_refspec(scm, self.git_url, refspec)
              if self.scm.get_ref(EXEC_BRANCH):
                  self.scm.remove_ref(EXEC_BRANCH)
  
      # checkout EXEC_HEAD and apply EXEC_MERGE on top of it without
      # committing
      assert isinstance(self.scm, Git)
      head = EXEC_BRANCH if branch else EXEC_HEAD
      self.scm.checkout(head, detach=True)
      merge_rev = self.scm.get_ref(EXEC_MERGE)
  
      self.scm.stash.apply(merge_rev)
      self._update_config(repo.config.read("local"))
  
imports: import os
  from contextlib import ExitStack
  from tempfile import mkdtemp
  from typing import TYPE_CHECKING, Optional, Union
  from configobj import ConfigObj
  from funcy import retry
  from shortuuid import uuid
  from dvc.lock import LockError
  from dvc.log import logger
  from dvc.repo.experiments.refs import EXEC_BASELINE, EXEC_BRANCH, EXEC_HEAD, EXEC_MERGE, EXEC_NAMESPACE, TEMP_NAMESPACE
  from dvc.repo.experiments.utils import EXEC_TMP_DIR, get_exp_rwlock
  from dvc.scm import SCM, Git
  from dvc.utils.fs import remove
  from dvc.utils.objects import cached_property
  from .base import BaseExecutor, TaskStatus
label_desc: Use image node_id 1 for calling the TempDirExecutor obj's underlying member method code with example usage: obj.init_git(repo, scm, stash_rev, entry, infofile, branch) without return types