{"record":{"id":"a17049b27cff77d3","repo":"sds/overcommit","slug":"does-not-appear-to-be-a-git-repository","errorCode":null,"errorMessage":"does not appear to be a git repository","messagePattern":"does not appear to be a git repository","errorType":"exception","errorClass":"Overcommit::Exceptions::InvalidGitRepo","httpStatus":null,"severity":"error","filePath":"lib/overcommit/installer.rb","lineNumber":97,"sourceCode":"    end\n\n    def ensure_directory(path)\n      FileUtils.mkdir_p(path)\n    end\n\n    def validate_target\n      absolute_target = File.expand_path(@target)\n\n      unless File.directory?(absolute_target)\n        raise Overcommit::Exceptions::InvalidGitRepo, 'is not a directory'\n      end\n\n      git_dir_check = Dir.chdir(absolute_target) do\n        Overcommit::Utils.execute(%w[git rev-parse --git-dir])\n      end\n\n      unless git_dir_check.success?\n        raise Overcommit::Exceptions::InvalidGitRepo, 'does not appear to be a git repository'\n      end\n    end\n\n    def install_master_hook\n      FileUtils.mkdir_p(hooks_path)\n      FileUtils.cp(MASTER_HOOK, master_hook_install_path)\n    end\n\n    def uninstall_master_hook\n      FileUtils.rm_rf(master_hook_install_path, secure: true)\n    end\n\n    def install_hook_files\n      # Copy each hook type (pre-commit, commit-msg, etc.) from the master hook.\n      Dir.chdir(hooks_path) do\n        Overcommit::Utils.supported_hook_types.each do |hook_type|\n          unless can_replace_file?(hook_type)\n            raise Overcommit::Exceptions::PreExistingHooks,","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/sds/overcommit/blob/fee0cd74b26eb81f64b43b7fab17bbb541575cc4/lib/overcommit/installer.rb#L79-L115","documentation":"After confirming the target is a directory, Installer runs 'git rev-parse --git-dir' inside it; if git exits non-zero there is no repository metadata, so it raises InvalidGitRepo 'does not appear to be a git repository'. Overcommit stores hooks and signatures under .git, so a valid repository is mandatory.","triggerScenarios":"'overcommit --install <dir>' on a directory never initialized with 'git init'; a repo whose .git was deleted or corrupted; a directory where GIT_DIR/GIT_WORK_TREE environment variables point somewhere invalid.","commonSituations":"New project where git init was forgotten; extracted source archive shipped without .git; partially deleted .git directory; CI job cloning into a custom path with broken GIT_* env.","solutions":["Initialize the repository first: 'git init <dir>' then 'overcommit --install <dir>'","If .git exists but is broken, verify with 'git status' and repair or re-clone before installing hooks","Check 'env | grep ^GIT_' - unset stale GIT_DIR/GIT_WORK_TREE values and retry"],"exampleFix":"# before\n$ overcommit --install .\ndoes not appear to be a git repository\n\n# after\n$ git init\n$ overcommit --install .","handlingStrategy":"validation","validationCode":"def git_repo?(dir)\n  system('git', '-C', dir, 'rev-parse', '--git-dir', out: File::NULL, err: File::NULL)\nend\n\nabort 'Not a git repository - run git init first' unless git_repo?(target)","typeGuard":"def git_repo?(dir)\n  Dir.chdir(dir) { system('git', 'rev-parse', '--git-dir', out: File::NULL, err: File::NULL) }\nend","tryCatchPattern":"begin\n  installer.run(target, action: :install)\nrescue Overcommit::Exceptions::InvalidGitRepo => e\n  abort \"#{target}: #{e.message} - run 'git init' first\"\nend","preventionTips":["Make 'git init' the first step of any new-project bootstrap script","Verify 'git rev-parse --git-dir' succeeds in CI before hook tooling runs"],"tags":["git","git-init","cli","overcommit"],"backgroundTag":"not-a-git-repository","analyzedSha":"fee0cd74b26eb81f64b43b7fab17bbb541575cc4","analyzedAt":"2026-08-23T04:07:28.153Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}