{"record":{"id":"a8170bf0cf3219d7","repo":"sds/overcommit","slug":"unable-to-determine-location-of-git-dir-not-a-rec","errorCode":null,"errorMessage":"Unable to determine location of GIT_DIR. Not a recognizable Git repository!","messagePattern":"Unable to determine location of GIT_DIR\\. Not a recognizable Git repository!","errorType":"exception","errorClass":"Overcommit::Exceptions::InvalidGitRepo","httpStatus":null,"severity":"error","filePath":"lib/overcommit/utils.rb","lineNumber":51,"sourceCode":"      attr_accessor :log\n\n      def script_path(script)\n        File.join(Overcommit::HOME, 'libexec', script)\n      end\n\n      # Returns an absolute path to the root of the repository.\n      #\n      # We do this ourselves rather than call `git rev-parse --show-toplevel` to\n      # solve an issue where the .git directory might not actually be valid in\n      # tests.\n      #\n      # @return [String]\n      def repo_root\n        @repo_root ||=\n          begin\n            result = execute(%w[git rev-parse --show-toplevel])\n            unless result.success?\n              raise Overcommit::Exceptions::InvalidGitRepo,\n                    'Unable to determine location of GIT_DIR. ' \\\n                    'Not a recognizable Git repository!'\n            end\n            result.stdout.chomp(\"\\n\")\n          end\n      end\n\n      # Returns an absolute path to the .git directory for a repo.\n      #\n      # @return [String]\n      def git_dir\n        @git_dir ||=\n          begin\n            cmd = %w[git rev-parse]\n            cmd << (GIT_VERSION < '2.5' ? '--git-dir' : '--git-common-dir')\n            result = execute(cmd)\n            unless result.success?\n              raise Overcommit::Exceptions::InvalidGitRepo,","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/sds/overcommit/blob/fee0cd74b26eb81f64b43b7fab17bbb541575cc4/lib/overcommit/utils.rb#L33-L69","documentation":"Error \"Unable to determine location of GIT_DIR. Not a recognizable Git repository!\" thrown in sds/overcommit.","triggerScenarios":"Thrown at lib/overcommit/utils.rb:51 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Run the command from inside a valid Git repository (or a subdirectory of one).","Verify `git rev-parse --show-toplevel` succeeds in the directory; fix or re-clone the repository if it is corrupt.","For non-standard layouts, set GIT_DIR and GIT_WORK_TREE environment variables appropriately."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fee0cd74b26eb81f64b43b7fab17bbb541575cc4","analyzedAt":"2026-08-23T04:07:28.153Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}