# Git: merge drivers and after a merge

The merge drivers prevent merge damage in the store; when it happened anyway, here is the repair.

## Merge drivers

`tkt git install` stops `.aitodo/counters.json` and the review files from conflicting on every merge of parallel branches. It writes only local git settings, for every worktree at once (nothing to commit); `tkt git uninstall` removes exactly that. `--dry-run` only shows it. Run it again after moving `tkt`.

### Details

- **It writes:** a marker block per store in `$(git-common-dir)/info/attributes` (not `.gitattributes`): `<store>/.aitodo/counters.json merge=aitodo-counters`, `<store>/reviews/**/*.yaml merge=aitodo-reviews`; `git config merge.aitodo-*.driver` = the running `tkt`'s absolute path (IDE merges work); `post-merge` / `post-rewrite` / `post-checkout` hooks in `git rev-parse --git-path hooks` (`core.hooksPath` counts) running, in the merge's worktree, the full re-check: `tkt index rebuild --quiet --workspace-dir "$(git rev-parse --show-toplevel)/<store>"`. After a merge of two branches that are each consistent it names the open reviews.
- Foreign hooks are untouched; the line is printed (`action: "manual"`). Outside git: `ERR_GIT_FAILED`.
- **The drivers** (git runs them): `tkt git merge-counters %O %A %B %P` writes the per-key max and raises the shared counter (unless `sharedCounter: false`; a non-counters side: exit 1, conflict). `tkt git merge-reviews` merges by record key.
- **An older install:** the retired decision view's driver (`merge=aitodo-view`, `merge.aitodo-view.*`) and hook command (`decision views refresh`) may be left from it; running `tkt git install` again removes them. `tkt doctor` prints `merge drivers: installed` / `not installed` / `reviews/**/*.yaml not covered` / `the retired decision-view driver is left in …`. CLI only.

- `tkt git install --json`: `{dryRun, repo, store, attributes: {path, block, changed}, config, configChanged, hooks: [{path, action: create|update|unchanged|manual, line}], legacyRemoved}`.
- Doctor JSON: `mergeDrivers` (`{installed, uncovered, stale, hint}`, `null` outside git).

## After a merge

After a `git merge`, run `tkt doctor`: a store file with conflict markers is `ERR_FILE_CONFLICT` for every command (file and first marker line).

- **Two tickets, one id** (two ULIDs): `tkt ticket resolve-conflict tickets/SG-160.md [--as SG-161]`: ours keeps the id, theirs gets the next free number, both get `## Notes`; `git add` both. One ULID (two edits): `ERR_SPLIT_REFUSED`, resolve by hand.
- **Decisions** (no ULID): `tkt decision resolve-conflict decisions/D63.md --split [--as D64]`.
- **`ERR_ID_DUPLICATE`** (two files, one `id` or `ulid`) and **`ERR_ID_MISMATCH`** (an `id` that is not the file name; decisions and milestones too): `tkt ticket renumber SG-160 [SG-161]` or `tkt decision renumber D63 [D64]`.
- All four: `--dry-run` (every file and field), `--json`, `--yes`; all or nothing.

### Details

- With a conflicted file, list commands skip it and name it once on stderr, a single read fails, a conflicted `.aitodo/config.yaml` or `counters.json` stops every command (doctor exits 4).
- `resolve-conflict` lists the files that still name the old id (they may have meant theirs) and never guesses. A decision without `--split` only shows both titles.
- Duplicates: list commands keep the first file and warn.
- `tkt ticket renumber`: a new id in its own group, any status; rewrites relationships, title and body mentions, milestone members and bodies, group/doc/gotcha bodies, decision origin/until/affects and bodies, the review store, dismiss lists; the ULID stays, `## Notes` records the old id (`tkt ticket move` likewise). `tkt decision renumber`: `decision://D63`, bare `D63`, `doc://<view> › D63` row aliases, other decisions' relationships, `supersededBy` and inherited/dropped `affects`, the review store; the views re-render.
- A failure restores store and counter. No REST counterpart.

## Commands on this page

- [`tkt git install`](/en/docs/reference/commands/maintenance.md#tkt-git-install): Set up the merge drivers in the repo that holds the store, for every worktree at once
- [`tkt git uninstall`](/en/docs/reference/commands/maintenance.md#tkt-git-uninstall): Remove exactly what `tkt git install` added for this store: its attributes block, its hook blocks, and the merge.aitodo-\* config once no store's block is left
- [`tkt ticket resolve-conflict`](/en/docs/reference/commands/ticket.md#tkt-ticket-resolve-conflict): Split a ticket file `git merge` left with conflict markers into its two creations
- [`tkt decision resolve-conflict`](/en/docs/reference/commands/knowledge.md#tkt-decision-resolve-conflict): Split a decision file `git merge` left with conflict markers into two decisions
- [`tkt ticket renumber`](/en/docs/reference/commands/ticket.md#tkt-ticket-renumber): Give a ticket a new id in its own group; every reference follows (any status)

## Related

- Error code · 422: [`ERR_FILE_CONFLICT`](/en/docs/reference/errors.md#ERR_FILE_CONFLICT): A store file holds git conflict markers
- Error code · 409: [`ERR_ID_DUPLICATE`](/en/docs/reference/errors.md#ERR_ID_DUPLICATE): Two objects share one id or ULID
- Error code · 422: [`ERR_ID_MISMATCH`](/en/docs/reference/errors.md#ERR_ID_MISMATCH): A file's frontmatter id is not its file name
- Error code · 409: [`ERR_SPLIT_REFUSED`](/en/docs/reference/errors.md#ERR_SPLIT_REFUSED): resolve-conflict: no markers, two edits of one ticket, or a decision without --split
