Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
setup: suggest 'git init' when no repository is found
When Git cannot find a .git directory, the error message now includes
a helpful hint suggesting to run 'git init' to initialize a new
repository. This helps new developers understand what to do when
they encounter this common error.

This follows the pattern established by the 'detected dubious ownership'
error message which provides actionable guidance to users.
  • Loading branch information
NotUnHackable committed Mar 11, 2026
commit b068be71a063e2290e85cfad3a1922ab96a98216
6 changes: 4 additions & 2 deletions setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -1881,14 +1881,16 @@ const char *setup_git_directory_gently(int *nongit_ok)
break;
case GIT_DIR_HIT_CEILING:
if (!nongit_ok)
die(_("not a git repository (or any of the parent directories): %s"),
die(_("not a git repository (or any of the parent directories): %s\n"
"See also the 'git init' command for initializing a new repository."),
DEFAULT_GIT_DIR_ENVIRONMENT);
*nongit_ok = 1;
break;
case GIT_DIR_HIT_MOUNT_POINT:
if (!nongit_ok)
die(_("not a git repository (or any parent up to mount point %s)\n"
"Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set)."),
"Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).\n"
"See also the 'git init' command for initializing a new repository."),
dir.buf);
*nongit_ok = 1;
break;
Expand Down
Loading