---
title: Team Collaboration
description: Share selected documents, understand per-document history, and coordinate edits across local replicas.
---

# Team Collaboration

GitKB separates the knowledge you hold locally from the documents you are editing. Pull the documents needed for a task, checkout the ones you will change, then commit and publish those changes.

## Two levels of selection

- **Selection** chooses the documents your local store holds and keeps in sync with a remote. A pull of a path adds it to the selection.
- **Checkout** materializes local documents in `.kb/workspaces/<name>/` for editing.

You can query committed local documents without checking them out. Each Git worktree has its own checkout workspace.

```mermaid
flowchart TD
    WA["Workspace A: pending edits"] -->|"commit"| LA["Local store A"]
    LA -->|"push whole commits"| R["Remote KB"]
    R -->|"pull selected history"| LB["Local store B"]
    LB -->|"checkout"| WB["Workspace B: editable Markdown"]
    WB -->|"commit"| LB
    LB -->|"push"| R
```

## Per-document history

A GitKB commit can contain changes to several documents. Each document keeps its own history, so ancestry follows the earlier changes to that document rather than one global branch.

```text
tasks/auth:  v1 -> v2 -> v3
specs/api:   v1 -> v2
```

Changes to unrelated documents can advance independently. Changes to the same document can diverge and require reconciliation. The receiver also validates history and commit integrity, so version mismatch is not the only reason a push can be rejected.

A new physical commit is published completely and atomically. Scoped push selects the work to publish; a multi-document commit still travels as a complete immutable object. Keep unrelated changes in separate commits when you want to share them independently.

A pull fetches the selected documents and their history. A retained shared commit may also mention other documents. Those incidental siblings are not automatically acquired as live documents or checked out. Shared commit bytes can still contain their change text, so a pathspec is not a redaction mechanism.

## Configure a remote

Use the sync URL supplied by the KB you want to share. A GitKB.com KB has the form `https://gitkb.com/api/v1/sync/<org>/<kb>`:

```bash
git-kb remote add origin https://gitkb.com/api/v1/sync/your-org/your-kb
git-kb remote list --json
git-kb login origin
```

The remote is recorded in `.kb/config.toml`. GitKB may record a GitKB.com URL in its short form, `gitkb://gitkb.com/your-org/your-kb`; both name the same KB. The first remote you add becomes the default remote (`sync.default_remote`), which bare `sync status` and `sync converge` act on.

For a token instead of sign-in, give a token source rather than the token itself: `--token-env <VAR>`, `--token-file <path>` or `--token-command <cmd>`. HTTP and HTTPS sync endpoints are also supported for self-hosted servers. Add other remotes with distinct names and remove one with `git-kb remote remove <name>`.

## Choose what you sync

A client syncs only its selection, a set of patterns per remote, read like Git's sparse-checkout cone mode. The default remote starts with `@local`: every document this store holds stays in sync with no decision. Widen or narrow it with `git-kb sync select`:

```bash
# Add patterns: a folder selects every document under it, now and later.
git-kb sync select tasks/ context/ --remote origin

# Select every document the remote has.
git-kb sync select --all --remote origin

# Replace the patterns instead of adding to them.
git-kb sync select --set context/ --remote origin

# Show the patterns and the documents they select.
git-kb sync select --list --remote origin
```

A document that leaves the selection is removed locally on the next `sync converge`, once its local commits are published; a checkout with uncommitted edits is held until you commit or clear it, and its log is kept.

The daemon converges the default remote in the background every `daemon.sync_interval_secs`, so a healthy KB stays in sync without commands. Any other remote is converged only when you run `git-kb sync converge <remote>`. Change the default with `git-kb config set sync.default_remote <name>`.

## Pull the documents you need

Push and pull require an explicit remote:

```bash
# Acquire documents, including ones not held locally.
git-kb pull origin tasks/auth-refactor --json
git-kb pull origin context/ --json
```

Quote globs so your shell does not expand them into local filenames. Pathspecs read the same way in push, pull, fetch, `sync status` and `sync converge` as in local commands; [Troubleshooting](/docs/reference/troubleshooting/#a-pathspec-matches-nothing-or-too-much) covers how they match and what a miss returns.

A pull without pathspecs refreshes locally held documents. To request every remote document explicitly, use `/` or the quoted `**`, which match every path (`*` matches top-level slugs only):

```bash
git-kb pull origin --json
git-kb pull origin '**' --json
```

There is no `pull --all` flag. To keep every remote document in sync, select them with `git-kb sync select --all`. Pulling all documents is a choice to expand your local replica; most task workflows can stay scoped.

## Edit and publish

```bash
git-kb checkout tasks/auth-refactor
git-kb workspace path tasks/auth-refactor --json
# Edit the returned workspace file.
git-kb diff
git-kb commit -m "Record auth refactor plan" tasks/auth-refactor --json
git-kb push origin tasks/auth-refactor
```

Use explicit document pathspecs for commits so other pending edits stay separate. Inspect what is held locally with `git-kb list --json`, and inspect checkout state with `git-kb workspace checkouts --json`.

## Coordinate task ownership

Assignment is a local check against the document's committed `assignee`. It stages the change for a separate commit:

```bash
git-kb assign tasks/auth-refactor agent-alex --json
git-kb set tasks/auth-refactor status=active
git-kb commit -m "Assign auth refactor" tasks/auth-refactor --json
git-kb push origin tasks/auth-refactor
```

Inspect ownership through the board:

```bash
git-kb board --unassigned --json
git-kb board --assigned-to agent-alex --json
```

After recording completion evidence, release the assignment and commit it:

```bash
git-kb unassign tasks/auth-refactor --json
git-kb commit -m "Release auth refactor assignment" tasks/auth-refactor --json
git-kb push origin tasks/auth-refactor
```

Assignment helps workers on a shared local KB or synchronized replicas see ownership. It is not a distributed lock: two disconnected replicas can both stage an assignment. Refresh before selecting work, publish claims promptly, and handle a rejected push before assuming ownership is shared.

## Read the plan, run the rows

`git-kb sync status` prints the engine's plan for a remote: one row per action, each with the command that runs it.

```bash
git-kb sync status origin --json
git-kb sync status origin --json -- tasks/auth-refactor
```

Each row has a tier that says who acts:

| Tier    | Meaning                                                            | What you do                                                             |
| ------- | ------------------------------------------------------------------ | ----------------------------------------------------------------------- |
| `auto`  | Pull, push, rebase and other steps that need no decision           | Run the row's command, or `git-kb sync converge origin` to run them all |
| `agent` | A decision: a conflict, a slug claim, a delete/edit, a selection   | Run the command the row prints, choosing one of its decisions           |
| `hold`  | The remote changed a document you have uncommitted edits to        | Run its command (a pull that merges into your file), then converge      |
| `info`  | Nothing to run                                                     | Nothing; the exit code ignores it                                       |
| `human` | Sign-in, an unreachable remote, an upgrade or an integrity problem | Stop and report the row; do not work around it                          |

`sync status` exits `0` at a fixed point (nothing to do), `70` when auto or agent rows are pending, `71` for a hold and `72` for a human row. `git-kb sync converge` runs the auto tier to a fixed point and stops at the first row that needs you. `git-kb sync show <row> --remote origin` prints a row's details; for a conflict, the base, both sides and the merge. `git-kb sync resolve <row> --remote origin --document <id> --decision <decision>` records an agent decision, exactly as the row's command carries it, then converges. A row still present after you ran its command is a result to report, not to retry.

### Resolve a conflict

A conflict means your unpublished commit and the remote tip changed the same or adjacent lines of a document. When a pull stops at one, the merge is left in the checked-out file with `<<<<<<< ours`, `||||||| base`, `=======` and `>>>>>>> theirs` blocks:

```bash
git-kb pull origin tasks/auth-refactor
git-kb rebase --json
# Edit each conflict block in the workspace file down to the content you want.
git-kb rebase --continue
git-kb push origin tasks/auth-refactor
```

To take one side whole, run `git-kb checkout --ours tasks/auth-refactor` or `git-kb checkout --theirs tasks/auth-refactor`, then continue. `git-kb rebase --abort` discards the stopped rebase.

A `conflict-N` row also prints a command that decides the whole document, such as `git-kb conflict accept tasks/auth-refactor --theirs <content-id> --local`. `--local` keeps your version, `--remote` takes the remote's and `--auto` takes the one modified more recently. Run it as printed, with one strategy; the `--theirs` value ties the decision to the remote content you saw.

## Share project guidance

Keep `.kb/AGENTS.md` and the harness entry points in your source repository so teammates use the same context and task conventions. KB document sync and Git source sync are separate: pulling KB documents does not update local scaffold files.

## Next steps

- [Agent Workflows](/docs/guides/agent-workflows/) — Context, ready tasks, and verification evidence
- [Documents](/docs/core-concepts/documents/) — Workspace-first edits and commits
- [Configuration](/docs/reference/configuration/) — Remote and daemon settings
- [Migration & Adoption](/docs/guides/migration/) — Roll out gradually
