{"record":{"id":"9f9c6f86ecdd37d1","repo":"facebook/docusaurus","slug":"git-not-installed-or-not-added-to-path","errorCode":null,"errorMessage":"Git not installed or not added to PATH!","messagePattern":"Git not installed or not added to PATH!","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/docusaurus/src/commands/deploy.ts","lineNumber":97,"sourceCode":"): Promise<void> {\n  const siteDir = await fs.realpath(siteDirParam);\n\n  const {outDir, siteConfig, siteConfigPath} = await loadContext({\n    siteDir,\n    config: cliOptions.config,\n    outDir: cliOptions.outDir,\n  });\n\n  if (typeof siteConfig.trailingSlash === 'undefined') {\n    logger.warn(`When deploying to GitHub Pages, it is better to use an explicit \"trailingSlash\" site config.\nOtherwise, GitHub Pages will add an extra trailing slash to your site urls only on direct-access (not when navigation) with a server redirect.\nThis behavior can have SEO impacts and create relative link issues.\n`);\n  }\n\n  logger.info('Deploy command invoked...');\n  if (!hasGit()) {\n    throw new Error('Git not installed or not added to PATH!');\n  }\n\n  // Source repo is the repo from where the command is invoked\n  const {stdout} = exec('git remote get-url origin', {\n    log: false,\n    failfast: true,\n  });\n  const sourceRepoUrl = stdout.trim();\n\n  // The source branch; defaults to the currently checked out branch\n  const sourceBranch =\n    process.env.CURRENT_BRANCH ??\n    exec('git rev-parse --abbrev-ref HEAD', {\n      log: false,\n      failfast: true,\n    })\n      ?.stdout?.toString()\n      .trim();","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/facebook/docusaurus/blob/3f483e80e326cc646b54b83d564b3f0c4881b9a6/packages/docusaurus/src/commands/deploy.ts#L79-L115","documentation":"Thrown early in deploy when `git --version` does not return exit code 0 (the hasGit() probe). Docusaurus deploy shells out to git repeatedly, so a missing git binary aborts immediately rather than failing later with a confusing error.","triggerScenarios":"Running `docusaurus deploy` in an environment without git installed or where git is not on PATH.","commonSituations":"Minimal Docker images (e.g. node:alpine without git), CI runners missing git, Windows machines where git is installed but not on PATH for the current shell.","solutions":["Install git (e.g. `apk add git` on alpine, `apt-get install git` on debian).","Ensure git is on PATH: `which git && git --version` must succeed in the deploy shell.","On Windows, restart the terminal after installing git so PATH updates take effect."],"exampleFix":"# before (alpine image)\ndocusaurus deploy  # throws 'Git not installed'\n# after\napk add --no-cache git\ndocusaurus deploy","handlingStrategy":"validation","validationCode":"import {execSync} from 'child_process';\nfunction gitAvailable(): boolean {\n  try { execSync('git --version', {stdio: 'ignore'}); return true; }\n  catch { return false; }\n}\nif (!gitAvailable()) throw new Error('Install git before deploying.');","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Install git in your CI/Docker image (`apk add git`, `apt-get install git`).","Verify `git --version` in the same shell that runs deploy.","On Windows, restart terminals after installing git."],"tags":["deploy","git","env","path"],"backgroundTag":null,"analyzedSha":"3f483e80e326cc646b54b83d564b3f0c4881b9a6","analyzedAt":"2026-08-12T13:25:04.382Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}