def initialize_git(self, project: Project) -> None:
        """Initialize a git repository if git is available and .git doesn't exist."""
        import shutil
        import subprocess

        if (project.root / ".git").exists():
            project.core.ui.info("Git repository already exists, skipping initialization.")
            return

        git_command = shutil.which("git")
        if not git_command:
            project.core.ui.info("Git command not found, skipping initialization.")
            return

        try:
            subprocess.run(
                [git_command, "init"],
                cwd=project.root,
                check=True,
                capture_output=True,
                encoding="utf-8",
            )
            project.core.ui.info("Git repository initialized successfully.")
        except subprocess.CalledProcessError as e:
            project.core.ui.error(f"Failed to initialize Git repository: {e.stderr}")
Initialize a git repository if git is available and .git doesn't exist.
src/pdm/cli/commands/init.py