---
title: Troubleshooting
description: Diagnose daemon, workspace, indexing, MCP, and sync problems with current GitKB commands.
---

# Troubleshooting

Start with the diagnostic for the subsystem that failed. Use `--json` where supported so identifiers and recovery instructions remain complete.

## Daemon connection or compatibility errors

```bash
git-kb daemon status --json
git-kb daemon logs --tail 100
```

The daemon can start automatically when a command needs it. To start a persistent background daemon yourself:

```bash
git-kb daemon start --background
```

`git-kb daemon start` without `--background` runs in the foreground. Use `git-kb daemon restart` after changing daemon configuration or updating GitKB. A compatibility refusal means the client and daemon need compatible protocol versions; follow the diagnostic before retrying the operation.

For a verbose foreground session:

```bash
git-kb --verbose daemon start
```

## Wrong KB or no documents

```bash
git-kb info
git-kb list --json
```

GitKB searches upward for a `.kb/` directory. Set `GITKB_ROOT=/path/to/project` to select a specific KB. An empty workspace and an empty KB are different: `status` describes checkouts, while `list` describes stored documents.

## MCP tools do not appear

Check the generated client configuration and the path to `git-kb`:

```bash
command -v git-kb
git-kb --version
git-kb daemon status --json
```

Run `git-kb init <harness> --dry-run` to inspect the integration assets your version would install. For a generic MCP client, configure a stdio server that runs `git-kb mcp`, with the project as its working directory or `GITKB_ROOT` set explicitly. Reload the client after changing its MCP configuration.

A raw `tools/list` line is not a complete MCP connection test: clients first initialize the protocol session, then list tools. Use your client's MCP status or logs to inspect that handshake.

## Old or unexpected workspace checkouts

Inspect the current worktree's workspace and changes:

```bash
git-kb workspace resolve --json
git-kb workspace checkouts --json
git-kb status --json
git-kb diff
```

Locate a document without assuming its workspace directory name:

```bash
git-kb workspace path tasks/my-task --json
```

Save changes with an explicit document scope:

```bash
git-kb commit -m "Save task changes" tasks/my-task
```

To discard edits to one document, run `git-kb reset tasks/my-task`. To remove its checkout, run `git-kb clear tasks/my-task`. Review the diff first. Metadata changes made by `git-kb set` also stay in the workspace until committed.

## A pathspec matches nothing or too much

`checkout`, `commit`, `rm`, `reset`, `clear` and `filter --rm` refuse a pathspec that matches nothing with exit 17 (`pathspec_no_match`). `details.pathspecs` names every miss, and nothing changes. `rm --force` skips such a pathspec instead. A lone old slug of a renamed document can be answered with exit 10 (`document_not_found`) naming the new slug. `/` and `**` mean every document and never miss.

Check how a pathspec reads. A document id is that document. `tasks/` is `tasks` and every document under it. `tasks/*` is the direct children, because `*`, `?` and `[…]` stay within one folder level; use `tasks/**` to cross folders. A bare `tasks` is the document at that slug when there is one, else the folder; `list --path`, `status` and `diff` read it as the folder. Push, pull, fetch, `sync status` and `sync converge` read pathspecs the same way; for them, a bare `context` is the document at that slug when one exists here or at the remote, else the folder. A pathspec that selects several documents needs `-r` for `rm`, `rm --hard` and `filter --rm`:

```bash
git-kb list --path tasks/ --json
git-kb rm -r tasks/old/
```

A purge (`rm --hard`, `filter --rm`) takes only ids, exact slugs, folders written with a trailing `/`, or globs. A bare name that no document holds, or a folder written without its trailing `/`, is refused with exit 4, even with `--force`. `rm --hard --force` skips any other unmatched name; `filter --rm --force` only confirms and still refuses it (exit 17).

## Semantic search has no results

Check the daemon, semantic index status, and embeddings:

```bash
git-kb daemon status --json
git-kb semantic status --json
```

Initialize the local semantic model and embed committed documents if the index is missing or stale:

```bash
git-kb semantic init
git-kb semantic index --json
```

If initialization fails, inspect `git-kb daemon logs --tail 100`. Model availability, backend support, and unembedded content can all affect results. See [Configuration](/docs/reference/configuration/) for embedding settings.

## Sync divergence or conflicts

Start with the plan for the remote. Replace `origin` with your configured remote name:

```bash
git-kb sync status origin --json
git-kb sync status origin --json -- 'tasks/*'
```

Run the rows in order. `auto` rows run with `git-kb sync converge origin`; an `agent` row prints the command for its decision; a `hold` row names the pull that merges into a file with uncommitted edits; a `human` row (sign-in, an unreachable remote, an upgrade, an integrity repair) is reported, not worked around. `sync status` exits `0` at a fixed point, `70` with auto or agent rows pending, `71` for a hold and `72` for a human row. A row still present after you ran its command is a result to report, not to retry. [Team Collaboration](/docs/guides/team-collaboration/#read-the-plan-run-the-rows) describes the tiers.

Inspect a row before deciding it:

```bash
git-kb sync show conflict-1 --remote origin
git-kb diff --three-way --remote origin --json -- 'tasks/*'
git-kb merge --preview origin --json -- 'tasks/*'
```

A scoped command that matches nothing is refused rather than answered for an empty scope. `push`, `pull` and `fetch` exit 17 (`pathspec_no_match`) and transfer nothing; `push` judges only the committed documents held here, and `pull` and `fetch` exit 4 for a document id found neither here nor at the remote. An online `sync status` exits 4 when nothing in the remote's selection matches, and names the `pull` or `sync select` that brings it in. `sync converge` runs what its other pathspecs match, lists the misses under `unmatched`, and exits 73 where it would have exited 0. An offline `sync status` never judges a pathspec. Stored selection patterns (`git-kb sync select`) keep their own grammar.

When a pull stops at a conflict, the merge is in the checked-out file. Inspect the stopped rebase, edit the conflict blocks, then continue:

```bash
git-kb rebase --json
git-kb status
# Edit the <<<<<<< ours / ||||||| base / ======= / >>>>>>> theirs blocks.
git-kb rebase --continue
```

`git-kb checkout --ours <document>` or `--theirs` takes one side whole; `git-kb rebase --abort` discards the stopped rebase. To decide a whole document instead, run the command its `conflict-N` row prints: `git-kb conflict accept <slug> --theirs <content-id>` with one of `--local` (keep yours), `--remote` (take the remote's) or `--auto` (the one modified more recently). `git-kb conflict show --json` lists the conflicts. A merge started with `git-kb merge` continues with `git-kb merge --continue` or stops with `git-kb merge --abort`.

Never edit files under `.kb/` other than workspace checkouts; GitKB manages the rest.

## Code intelligence returns empty or stale results

```bash
git-kb code stats --json
git-kb code doctor --json
git-kb doctor --check repos --json
git-kb workspace list --json
git-kb repo list --json
```

Check repository discovery, the query branch, and linked-worktree registration. Index the intended source directory, then query a known file:

```bash
git-kb code index src/
git-kb code symbols --file src/main.rs --json
```

With the daemon running, file watching maintains the index after saves. Missing worktree registration, excluded paths, unsupported languages, or a different default branch can explain missing results. [Code Intelligence](/docs/core-concepts/code-intelligence/) describes branch queries and index scope.

## Socket permissions

On Unix, daemon state normally lives under `.kb/.cache/`, including `gitkb.sock`. Check the actual path and owner reported by `git-kb daemon status --json`. Use `git-kb daemon stop` and `git-kb daemon start --background` to restart the service. Do not remove a socket while its daemon is running; inspect the ownership error and correct access to the KB directory first.

## Integrity checks

| Command                            | Scope                                                                  |
| ---------------------------------- | ---------------------------------------------------------------------- |
| `git-kb doctor --json`             | Repository discovery, code, and KB diagnostics with suggested actions. |
| `git-kb fsck --json`               | Local KB integrity checks.                                             |
| `git-kb verify --json`             | Canonical file store integrity.                                        |
| `git-kb info`                      | KB statistics and storage information.                                 |
| `git-kb sync status origin --json` | The sync plan for a remote: its rows and their commands.               |

`git-kb doctor --fix` applies the safe local repairs it supports and reruns checks. Inspect the diagnostic first to choose the relevant repair.

## Report an issue

Collect the failing command, its output, `git-kb --version`, and steps to reproduce. Redact credentials from configuration and logs.

The feedback command works without a KB or sign-in. Preview a report before sending it:

```bash
git-kb feedback --category bug --message "Steps to reproduce..." --dry-run --json
```

Bug reports attach `doctor --json` output. `--include-diagnostics` additionally collects bounded system and tool details. Remove `--dry-run` when you want to submit the report. You can also use the [GitKB issue tracker](https://github.com/gitkb/gitkb-releases/issues).

## Related docs

- [Configuration](/docs/reference/configuration/) — Project settings.
- [Daemon](/docs/core-concepts/daemon/) — Background service behavior.
- [CLI Reference](/docs/cli-reference/) — Installed command help.
