yamadashy/repomix · error · RepomixError
Failed to get git logs: ${(error as Error).message}
Error message
Failed to get git logs: ${(error as Error).message} What it means
getGitLogs executes git log commands to build commit history output and, on any failure, re-throws as a RepomixError with this message, the underlying git error text appended, and the original error preserved as `cause`. Failures typically mean git could not run or the path is not a repository.
Source
Thrown at src/core/git/gitLogHandle.ts:109
let gitLogResult: GitLogResult | undefined;
if (config.output.git?.includeLogs) {
try {
// Use the first directory as the git repository root
// Usually this would be the root of the project
const gitRoot = rootDirs[0] || config.cwd;
const maxCommits = config.output.git?.includeLogsCount || 50;
const logContent = await deps.getGitLog(gitRoot, maxCommits);
// Parse the raw log content into structured commits
const commits = parseGitLog(logContent);
gitLogResult = {
logContent,
commits,
};
} catch (error) {
throw new RepomixError(`Failed to get git logs: ${(error as Error).message}`, { cause: error });
}
}
return gitLogResult;
};
View on GitHub (pinned to f465ad9093)
Solutions
- Run inside a valid git repository, or `git init && git commit` if history is intentionally absent.
- Install/verify git: `git --version` must succeed in the same environment.
- Inspect the appended message and error.cause for the exact git failure and fix it (e.g. repair history, clear index.lock).
Example fix
// before (folder without .git) npx repomix ./exported-folder // Failed to get git logs // after cd exported-folder && git init && git add -A && git commit -m init npx repomix .
Defensive patterns
Strategy: try-catch
Validate before calling
import { execFileSync } from 'node:child_process';
const hasGitHistory = (dir: string) => {
try { execFileSync('git', ['-C', dir, 'log', '-1'], { stdio: 'ignore' }); return true; }
catch { return false; }
};
if (!hasGitHistory(targetDir)) throw new Error('No git history available; git logs cannot be collected.'); Type guard
const isGitLogError = (e: unknown): e is RepomixError =>
e instanceof RepomixError && e.message.startsWith('Failed to get git logs:'); Try / catch
try {
const logs = await getGitLogs(...);
} catch (error) {
if (isGitLogError(error)) {
console.warn('Git log collection skipped:', error.message, 'cause:', error.cause);
} else throw error;
} Prevention
- Run against directories that contain a .git folder with at least one commit.
- Install git in CI/Docker images used for packing.
- Check error.cause for the exact git stderr when diagnosing.
- Skip log-dependent options when processing archives or exports without history.
When it happens
Trigger: Calling getGitLogs (or the git-log processing path) when git is missing from PATH, the target directory has no .git, the directory is a bare/unusual repo, or the git log subprocess exits non-zero.
Common situations: Running on a copied folder without .git; minimal CI images without git installed; repos with zero commits or corrupted history; shallow clones with unusual configs.
Related errors
- Failed to get git diffs: ${error.message}
- Git is not installed or not in the system PATH.
- Failed to clone repository: ${redactErrorMessage(error)}
- Invalid repository URL. URL contains potentially dangerous p
- Invalid URL protocol for '${redactUrl(url)}'. URL must start
AI-assisted analysis of yamadashy/repomix@f465ad9093 (2026-08-29).
Data as JSON: /api/errors/da5bcea4d9712eb7.
Report an issue: GitHub.