sds/overcommit · error · Overcommit::Exceptions::InvalidGitRepo
Unable to determine location of GIT_DIR. Not a recognizable
Error message
Unable to determine location of GIT_DIR. Not a recognizable Git repository!
What it means
Error "Unable to determine location of GIT_DIR. Not a recognizable Git repository!" thrown in sds/overcommit.
Source
Thrown at lib/overcommit/utils.rb:51
attr_accessor :log
def script_path(script)
File.join(Overcommit::HOME, 'libexec', script)
end
# Returns an absolute path to the root of the repository.
#
# We do this ourselves rather than call `git rev-parse --show-toplevel` to
# solve an issue where the .git directory might not actually be valid in
# tests.
#
# @return [String]
def repo_root
@repo_root ||=
begin
result = execute(%w[git rev-parse --show-toplevel])
unless result.success?
raise Overcommit::Exceptions::InvalidGitRepo,
'Unable to determine location of GIT_DIR. ' \
'Not a recognizable Git repository!'
end
result.stdout.chomp("\n")
end
end
# Returns an absolute path to the .git directory for a repo.
#
# @return [String]
def git_dir
@git_dir ||=
begin
cmd = %w[git rev-parse]
cmd << (GIT_VERSION < '2.5' ? '--git-dir' : '--git-common-dir')
result = execute(cmd)
unless result.success?
raise Overcommit::Exceptions::InvalidGitRepo,View on GitHub (pinned to fee0cd74b2)
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.
When it happens
Trigger: Thrown at lib/overcommit/utils.rb:51 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of sds/overcommit@fee0cd74b2 (2026-08-23).
Data as JSON: /api/errors/a8170bf0cf3219d7.
Report an issue: GitHub.