sds/overcommit · error · Overcommit::Exceptions::GitConfigError
Unable to read from local repo git config: #{result.stderr}
Error message
Unable to read from local repo git config: #{result.stderr} What it means
HookSigner#stored_signature reads the plugin signature with 'git config --local --get overcommit.<HookType>.<Hook>.signature'. Exit status 1 (key absent) is normal and returns an empty string, but any other non-zero exit raises GitConfigError with git's stderr - git could not read or parse the local config at all. This runs on every hook invocation because the runner compares stored and computed signatures.
Source
Thrown at lib/overcommit/hook_signer.rb:113
hook_contents
end
Digest::SHA256.hexdigest(content_to_sign.to_s + hook_config.to_s)
end
def hook_contents
File.read(hook_path)
end
def stored_signature
result = Overcommit::Utils.execute(
%w[git config --local --get] + [signature_config_key]
)
if result.status == 1 # Key doesn't exist
return ''
elsif result.status != 0
raise Overcommit::Exceptions::GitConfigError,
"Unable to read from local repo git config: #{result.stderr}"
end
result.stdout.chomp
end
def signature_config_key
"overcommit.#{@context.hook_class_name}.#{@hook_name}.signature"
end
end
end
View on GitHub (pinned to fee0cd74b2)
Solutions
- Reproduce with 'git config --local --list' - it names the offending line; fix or remove that line in .git/config
- If the file is unfixable, re-create the essentials (remotes, user settings) and re-run 'overcommit --sign' to rewrite the signature keys
- Verify you are inside the repo: 'git rev-parse --git-dir' must print a path; re-run hooks from the repo root
- Re-run the hook or 'overcommit --sign <hook-type>' once the config parses again
Example fix
# before (.git/config contains)
[core]
repositoryformatversion <<<<<<< HEAD
# after
[core]
repositoryformatversion = 0 Defensive patterns
Strategy: validation
Validate before calling
def git_config_parseable?
system('git', 'config', '--local', '--list', out: File::NULL, err: File::NULL)
end
abort '.git/config is not parseable - fix it before running hooks' unless git_config_parseable? Try / catch
begin
runner.run
rescue Overcommit::Exceptions::GitConfigError => e
warn "Cannot read git config: #{e.message}"
warn 'Run: git config --local --list # shows the offending line'
exit 1
end Prevention
- Set config values via 'git config' commands instead of editing .git/config by hand
- After merge/rebase trouble, sanity-check 'git config --local --list' before committing
- Never leave conflict markers anywhere under .git
When it happens
Trigger: git exits non-zero (typically 128) with 'bad config line N in .git/config' (corrupted config or unresolved conflict markers), 'not in a git directory' when run outside a valid work tree, or permission errors reading .git/config.
Common situations: Hand-edited .git/config with a typo; merge/submodule trouble left conflict markers in .git/config; hooks invoked with GIT_DIR pointing at a broken path; CI checkouts where .git is mangled.
Related errors
- Unable to write to local repo git config: #{result.stderr}
- Hook specified a `required_executable` or `command` that is
- does not appear to be a git repository
- Hook '#{File.expand_path(hook_type)}' already exists and was
- Class #{hook_name} is not a subclass of #{hook_base_class}.
AI-assisted analysis of sds/overcommit@fee0cd74b2 (2026-08-23).
Data as JSON: /api/errors/ae500e44e20b558a.
Report an issue: GitHub.