{"record":{"id":"55ec97516e06d5e0","repo":"crewAIInc/crewAI","slug":"self-path-is-not-a-git-repository","errorCode":null,"errorMessage":"{self.path} is not a Git repository.","messagePattern":"(.+?) is not a Git repository\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"lib/cli/src/crewai_cli/git.py","lineNumber":35,"sourceCode":"    \".tox/\",\n    \".venv/\",\n    \"__pycache__/\",\n    \"build/\",\n    \"dist/\",\n    \"env/\",\n    \"venv/\",\n]\n\n\nclass Repository:\n    def __init__(self, path: str = \".\", fetch: bool = True) -> None:\n        self.path = path\n\n        if not self.is_git_installed():\n            raise ValueError(\"Git is not installed or not found in your PATH.\")\n\n        if not self.is_git_repo:\n            raise ValueError(f\"{self.path} is not a Git repository.\")\n\n        if fetch:\n            self.fetch()\n\n    @staticmethod\n    def is_git_installed() -> bool:\n        \"\"\"Check if Git is installed and available in the system.\"\"\"\n        try:\n            subprocess.run(\n                [\"git\", \"--version\"],  # noqa: S607\n                capture_output=True,\n                check=True,\n                text=True,\n            )\n            return True\n        except (subprocess.CalledProcessError, FileNotFoundError):\n            return False\n","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/crewAIInc/crewAI/blob/754d7323beb2fd042e33444a115ea2d5a47193f0/lib/cli/src/crewai_cli/git.py#L17-L53","documentation":"Raised by Repository.__init__ when the given path is not inside a Git work tree (the `git rev-parse`-backed is_git_repo check fails) — git is installed, but there is no repository at self.path. Deploy flows require a repo to compute remotes/commits, so construction aborts. The message interpolates the offending path.","triggerScenarios":"Running `crewai deploy create` in a freshly scaffolded crew that has never been `git init`-ed; constructing Repository('/some/dir') where no .git exists; running the CLI one directory above/below the actual repo without git's upward discovery applying (e.g. path explicitly set wrong).","commonSituations":"New project scaffolds not yet initialized, downloading/copying a project without its .git folder, running deploy commands in a temp/scratch directory, or path typos in programmatic usage.","solutions":["cd into the project and initialize: `git init && git add . && git commit -m 'init'`","Or use Repository.initialize('.') / the CLI flow that creates the repo and initial commit for you","Verify with `git -C <path> status` that the path is a work tree before running deploy","Fix the path argument if you pointed Repository at the wrong directory"],"exampleFix":"# before\nrepo = Repository(path='./my-crew')  # ValueError: ./my-crew is not a Git repository.\n# after\nrepo = Repository.initialize(path='./my-crew')  # inits repo + initial commit, no fetch","handlingStrategy":"validation","validationCode":"import subprocess\n\ndef is_git_worktree(path: str) -> bool:\n    return subprocess.run(\n        [\"git\", \"-C\", path, \"rev-parse\", \"--is-inside-work-tree\"],\n        capture_output=True,\n    ).returncode == 0","typeGuard":null,"tryCatchPattern":"try:\n    repo = Repository(path)\nexcept ValueError as e:\n    if \"is not a Git repository\" in str(e):\n        repo = Repository.initialize(path)  # or git init manually first\n    else:\n        raise","preventionTips":["git init + initial commit immediately after scaffolding a crew","Use Repository.initialize for local-only projects","Double-check path arguments before constructing Repository"],"tags":["git","validation","deployment","cli"],"backgroundTag":null,"analyzedSha":"754d7323beb2fd042e33444a115ea2d5a47193f0","analyzedAt":"2026-08-15T04:06:56.746Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}