code: def git_repo_fn() -> Generator:
      def git_repo_fn_helper(
          path: str = ".",
          remote_name: str = "origin",
          remote_url: Optional[
              str
          ] = "https://foo:bar@github.com/FooTest/Foo.git",
          commit_msg: Optional[str] = None,
      ):
          with git.Repo.init(path) as repo:
              if remote_url is not None:
                  repo.create_remote(remote_name, remote_url)
              if commit_msg is not None:
                  repo.index.commit(commit_msg)
              return GitRepo(lazy=False)
  
      yield git_repo_fn_helper
  
file_path: wandb/tests/pytest_tests/unit_tests/test_lib/test_git.py
imports: from typing import Generator, Optional
  import git
  import pytest
  from wandb.sdk.lib.gitlib import GitRepo
label_desc: Use image node_id 1 for calling a global function with example usage: git_repo_fn() and returns: GitRepo