{"record":{"id":"229a722c0d811f3f","repo":"facebook/docusaurus","slug":"docusaurus-failed-to-run-the-git-log-to-retrieve","errorCode":null,"errorMessage":"Docusaurus failed to run the 'git log' to retrieve tracked files last update date/author.\nThe command exited with code ${result.exitCode}: ${result.stderr}","messagePattern":"Docusaurus failed to run the 'git log' to retrieve tracked files last update date/author\\.\nThe command exited with code (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/docusaurus-utils/src/vcs/gitUtils.ts","lineNumber":472,"sourceCode":"      'log',\n      // Format each history entry as t:<seconds since epoch>\n      '--format=t:%ct,a:%an',\n      // In each entry include the name and status for each modified file\n      '--name-status',\n\n      // For creation info, should we use --follow --find-renames=100% ???\n    ],\n    {\n      cwd,\n      encoding: 'utf-8',\n      // TODO use streaming to avoid a large buffer\n      // See https://github.com/withastro/starlight/issues/3154\n      maxBuffer: 20 * 1024 * 1024,\n    },\n  );\n\n  if (result.exitCode !== 0) {\n    throw new Error(\n      `Docusaurus failed to run the 'git log' to retrieve tracked files last update date/author.\nThe command exited with code ${result.exitCode}: ${result.stderr}`,\n    );\n  }\n\n  const logLines = result.stdout.split('\\n');\n\n  const now = Date.now();\n\n  // TODO not fail-fast\n  let runningDate = now;\n  let runningAuthor = 'N/A';\n  const runningMap: GitFileInfoMap = new Map();\n\n  for (const logLine of logLines) {\n    if (logLine.startsWith('t:')) {\n      // t:<timestamp>,a:<author name>\n      // We can't use split(',') because author names may contain commas","sourceCodeStart":454,"sourceCodeEnd":490,"githubUrl":"https://github.com/facebook/docusaurus/blob/3f483e80e326cc646b54b83d564b3f0c4881b9a6/packages/docusaurus-utils/src/vcs/gitUtils.ts#L454-L490","documentation":"Thrown by getGitRepositoryFilesInfo when `git --no-pager -c log.showSignature=false log --format=t:%ct,a:%an --name-status` exits non-zero. This is the command Docusaurus uses to compute each tracked file's last-update time and author. The error message includes the exit code and stderr for diagnosis. maxBuffer is set to 20 MB so huge repos are tolerated, but git-side failures still surface here.","triggerScenarios":"Running in a repo with no commits (empty HEAD), with a broken HEAD, with a corrupt object database, or where git log fails for another reason (e.g. bad gc state).","commonSituations":"Freshly `git init`'d repo with no commits, shallow clone whose history is truncated in a way that breaks log, repo interrupted during `git gc`, or a detached/empty HEAD.","solutions":["Make at least one commit so `git log` has history: `git commit --allow-empty -m init`.","Run `git fsck --full` and repair any reported corruption.","Re-clone if the object database is damaged: `git log` must succeed on its own first.","For shallow clones, ensure history is complete enough: `git fetch --unshallow` if needed."],"exampleFix":"// before\n// repo exists but has zero commits -> `git log` exits non-zero\n// after\ngit commit --allow-empty -m \"initial commit\"\ndocusaurus build","handlingStrategy":"validation","validationCode":"import {execSync} from 'child_process';\nfunction hasGitHistory(cwd: string): boolean {\n  try {\n    execSync('git log --oneline -1', {cwd, stdio: 'ignore'});\n    return true;\n  } catch { return false; }\n}","typeGuard":null,"tryCatchPattern":"try {\n  await getGitRepositoryFilesInfo(cwd);\n} catch (e) {\n  if (/git log/.test(String(e))) disableLastUpdateFeatures();\n  else throw e;\n}","preventionTips":["Always create at least one commit before building.","Run `git fsck` periodically to catch corruption early.","Avoid broken shallow clones; unshallow if log fails."],"tags":["git","vcs","git-log","history"],"backgroundTag":null,"analyzedSha":"3f483e80e326cc646b54b83d564b3f0c4881b9a6","analyzedAt":"2026-08-12T13:25:04.382Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}