{"record":{"id":"cba6c2a8d4419bd1","repo":"sds/overcommit","slug":"unable-to-write-to-local-repo-git-config-result-cba6c2","errorCode":null,"errorMessage":"Unable to write to local repo git config: #{result.stderr}","messagePattern":"Unable to write to local repo git config: #(.+?)","errorType":"exception","errorClass":"Overcommit::Exceptions::GitConfigError","httpStatus":null,"severity":"error","filePath":"lib/overcommit/hook_signer.rb","lineNumber":76,"sourceCode":"        file.start_with?(Overcommit::Utils.repo_root)\n    end\n\n    # Return whether the signature for this hook has changed since it was last\n    # calculated.\n    #\n    # @return [true,false]\n    def signature_changed?\n      signature != stored_signature\n    end\n\n    # Update the current stored signature for this hook.\n    def update_signature!\n      result = Overcommit::Utils.execute(\n        %w[git config --local] + [signature_config_key, signature]\n      )\n\n      unless result.success?\n        raise Overcommit::Exceptions::GitConfigError,\n              \"Unable to write to local repo git config: #{result.stderr}\"\n      end\n    end\n\n    private\n\n    # Calculates a hash of a hook using a combination of its configuration and\n    # file contents.\n    #\n    # This way, if either the plugin code changes or its configuration changes,\n    # the hash will change and we can alert the user to this change.\n    def signature\n      hook_config = @config.for_hook(@hook_name, @context.hook_class_name).\n                            dup.\n                            tap { |config| IGNORED_CONFIG_KEYS.each { |k| config.delete(k) } }\n\n      content_to_sign =\n        if signable_file?(hook_path) && Overcommit::GitRepo.tracked?(hook_path)","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/sds/overcommit/blob/fee0cd74b26eb81f64b43b7fab17bbb541575cc4/lib/overcommit/hook_signer.rb#L58-L94","documentation":"Overcommit stores each hook's signature under a local git config key (overcommit.<HookType>.<HookName>.signature) by running 'git config --local'. HookSigner#update_signature! raises GitConfigError with git's stderr when that write exits non-zero - git refused to modify .git/config.","triggerScenarios":"Running 'overcommit --sign <hook-type>' (or the install-time auto-sign) while .git/config.lock exists from a crashed or concurrent git process ('Unable to create .git/config.lock: File exists.'), .git/config is corrupted ('bad config line'), the user lacks write permission on .git, or the environment is not inside a valid work tree.","commonSituations":"IDE and CLI git tools writing config at the same moment; stale .git/config.lock after a crash; repo restored with different ownership (root-owned .git inside a container); read-only .git in CI artifacts.","solutions":["Confirm no git process is running, then remove the stale lock: 'rm -f .git/config.lock' and re-run 'overcommit --sign <hook-type>'","Inspect .git/config for conflict markers or malformed lines ('git config --local --list' reproduces the parse error) and fix them","Fix ownership/permissions of the .git directory (e.g. 'chown -R $(id -u):$(id -g) .git') if the write is denied","Re-run the failed overcommit command once the underlying cause is cleared"],"exampleFix":"# before\n$ overcommit --sign pre-commit\nOvercommit::Exceptions::GitConfigError: Unable to write to local repo git config: fatal: Unable to create '/repo/.git/config.lock': File exists.\n\n# after\n$ rm -f .git/config.lock\n$ overcommit --sign pre-commit","handlingStrategy":"retry","validationCode":"def git_config_writable?\n  git_dir = `git rev-parse --git-dir`.strip\n  !File.exist?(File.join(git_dir, 'config.lock')) && File.writable?(File.join(git_dir, 'config'))\nend\n\nraise 'git config locked or unwritable' unless git_config_writable?","typeGuard":null,"tryCatchPattern":"begin\n  signer.update_signature!\nrescue Overcommit::Exceptions::GitConfigError => e\n  raise unless e.message.include?('config.lock') && File.exist?('.git/config.lock')\n  File.delete('.git/config.lock')\n  retry\nend","preventionTips":["Avoid running two git-config-writing tools at once (close IDE git integrations while signing)","Remove .git/config.lock after any crashed git process","Keep .git owned by the user running overcommit"],"tags":["git","git-config","lock-file","permissions","overcommit"],"backgroundTag":"git-config-write-failed","analyzedSha":"fee0cd74b26eb81f64b43b7fab17bbb541575cc4","analyzedAt":"2026-08-23T04:07:28.153Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}