facebook/docusaurus · error

Docusaurus failed to run the 'git log' to retrieve tracked f

Error message

Docusaurus failed to run the 'git log' to retrieve tracked files last update date/author.
The command exited with code ${result.exitCode}: ${result.stderr}

What it means

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.

Source

Thrown at packages/docusaurus-utils/src/vcs/gitUtils.ts:472

      'log',
      // Format each history entry as t:<seconds since epoch>
      '--format=t:%ct,a:%an',
      // In each entry include the name and status for each modified file
      '--name-status',

      // For creation info, should we use --follow --find-renames=100% ???
    ],
    {
      cwd,
      encoding: 'utf-8',
      // TODO use streaming to avoid a large buffer
      // See https://github.com/withastro/starlight/issues/3154
      maxBuffer: 20 * 1024 * 1024,
    },
  );

  if (result.exitCode !== 0) {
    throw new Error(
      `Docusaurus failed to run the 'git log' to retrieve tracked files last update date/author.
The command exited with code ${result.exitCode}: ${result.stderr}`,
    );
  }

  const logLines = result.stdout.split('\n');

  const now = Date.now();

  // TODO not fail-fast
  let runningDate = now;
  let runningAuthor = 'N/A';
  const runningMap: GitFileInfoMap = new Map();

  for (const logLine of logLines) {
    if (logLine.startsWith('t:')) {
      // t:<timestamp>,a:<author name>
      // We can't use split(',') because author names may contain commas

View on GitHub (pinned to 3f483e80e3)

Solutions

  1. Make at least one commit so `git log` has history: `git commit --allow-empty -m init`.
  2. Run `git fsck --full` and repair any reported corruption.
  3. Re-clone if the object database is damaged: `git log` must succeed on its own first.
  4. For shallow clones, ensure history is complete enough: `git fetch --unshallow` if needed.

Example fix

// before
// repo exists but has zero commits -> `git log` exits non-zero
// after
git commit --allow-empty -m "initial commit"
docusaurus build
Defensive patterns

Strategy: validation

Validate before calling

import {execSync} from 'child_process';
function hasGitHistory(cwd: string): boolean {
  try {
    execSync('git log --oneline -1', {cwd, stdio: 'ignore'});
    return true;
  } catch { return false; }
}

Try / catch

try {
  await getGitRepositoryFilesInfo(cwd);
} catch (e) {
  if (/git log/.test(String(e))) disableLastUpdateFeatures();
  else throw e;
}

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of facebook/docusaurus@3f483e80e3 (2026-08-12). Data as JSON: /api/errors/229a722c0d811f3f. Report an issue: GitHub.