Skip to content

Suppress "fatal: not a git repository" warning when running outside a git repo #260

Description

@almax000

Description

When starting Deep Code in a directory that is not a git repository (and has no parent git repo), git outputs the following warning to stderr:

fatal: not a git repository (or any of the parent directories): .git

This happens every time Deep Code is launched or a new session is started in a non-git directory.

Cause

Deep Code likely runs git rev-parse --show-toplevel (or similar) at startup to detect the project root directory. When no .git directory exists anywhere in the path, git itself emits this fatal error to stderr.

Expected behavior

Deep Code should either:

  1. Suppress git stderr when probing for the repo root (e.g., redirect stderr to /dev/null), or
  2. Use a fallback approach that does not depend on git (e.g., using process.cwd() directly when git fails), or
  3. At minimum, silently handle the case where no git repo is present instead of leaking the raw git error to the user.

Steps to reproduce

  1. Create a directory with no .git subdirectory and no parent git repo
  2. Run deepcode in that directory
  3. Observe the fatal: not a git repository message

Environment

  • Deep Code CLI v0.1.34
  • macOS (likely reproducible on all platforms)

Additional context

This is purely cosmetic — Deep Code still functions correctly afterwards. However, the error message is confusing to users who may not be using git at all, and it clutters the terminal output unnecessarily.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions