Getting started
GitWhy has two interaction modes:- CLI — non-interactive output for scripting and piping
- TUI — auto-opens an interactive terminal UI when stdout is a TTY
Command overview
git why setup
Set up GitWhy globally and configure coding-agent integrations.
git why save in each repository. That first save installs the post-commit hook, prepares .git/gitwhy/ local storage, saves repo-scoped credentials, and configures notes.rewriteRef.
If you run git why setup inside a Git repository, GitWhy also registers that repository in your workspace.
Flags:
Examples:
git why save
Save structured context from stdin or a file.
--file, injects metadata (context ID, commits), auto-categorizes, and stores the result under .git/gitwhy/contexts/.
Accepts either XML format (preferred — wrap content in <context> tags) or Markdown format (legacy — use ## Section headings).
Flags:
Required fields (XML format):
<title>, <story>, <reasoning>
Required fields (Markdown format): ## Prompt, ## What Was Done, ## Reasoning
Context ID, repository, branch, date, and commits are auto-populated in both formats.
Examples:
git why get
Retrieve a saved context by ID.
Examples:
git why log
List all saved contexts.
git why tree
Display the domain and topic context tree.
git why log, opens the TUI when stdout is a terminal. In non-interactive output, prints the tree in plain text.
Output:
git why search
Search saved contexts using hybrid full-text search across local and cloud workspace contexts.
Flags:
Output:
git why push
Sync specific contexts to GitWhy cloud. Requires one or more context IDs.
--share to publish them as team-visible.
Flags:
Output:
Requires credentials. If none are available, the CLI exits with:
missing API key. Run 'git why setup' first.
Run git why log to see available context IDs.git why post-pr
Post context summary as a PR comment. Contexts are matched to the PR by verifying commit SHAs or branch name.
PR auto-detection: When no
--pr or --branch is specified, GitWhy first checks the current branch for an open PR. If none is found, it scans all open PRs and matches them against branches in your saved contexts. This means you can run git why post-pr from main and it will find PRs for contexts saved on feature branches.
Output:
Requires the GitHub App installed on the repository, a GitWhy API key, and the GitHub CLI (
gh) authenticated.
Contexts are auto-synced and published before posting.Help behavior
GitWhy uses Cobra help flags across all commands:git why <command> -h— shows the command helpgit why <command> --help— shows the command helpgit why <command> -help— invalid (parsed as short flags)
See also
- TUI — interactive terminal interface
- MCP Server — agent tool interface
- Context Format — template and field definitions