Skip to content

Git Plugin

The Git plugin provides Titan's core Git workflow surface. It exposes:

  • a high-level GitClient for direct use from Titan code
  • reusable workflow steps such as get_status, create_commit, and push
  • the built-in commit-ai and merge-branch workflows

Requirements

To use the Git plugin in a project:

  • Enable the git plugin in .titan/config.toml
  • Install the git CLI and make sure it is available in PATH
  • Run Titan inside a Git repository

Example project configuration:

[plugins.git]
enabled = true

[plugins.git.config]
main_branch = "main"
default_remote = "origin"

Public surfaces

Mod

The plugin ships the git mod: a side-panel pane with the branch you are on, read through GitClient on timers and refreshed after every workflow. It shows the branch, how it stands against its upstream (↑ahead ↓behind) and how many lines are uncommitted; under it the same branch toolbar as the workspace (the switcher behind the branch selector, and the actions row; see Workspace below), drawn for the pane's width, so most actions sit behind ⋯; ⤒ Stashes (N) when there are stashes, which opens the workspace on the newest; and Open Git workspace for everything else (the history, the stashes and the worktrees).

What the toolbar's actions do, in the pane and in the workspace alike:

  • ✦ Commit — the commit_workflow (commit-ai), first on the row while the tree is dirty. While the working tree has modified or staged files the toolbar turns amber and says so; untracked files never block a switch.
  • ⇩ Pull and ⇧ Push, with how far behind or ahead the branch is. From the press until git answers, the row is replaced by a … pulling origin/<branch> line, so a second press cannot start the same thing twice. A push git refuses is reported as git worded it, with the reason — nothing here forces one, since that would drop the remote's commits; the pull stays with a dirty tree, since git decides for itself whether it is safe.
  • ⬈ PR — the create_pr_workflow (create-pr-ai from titan-plugin-github by default), or the project workflow extending it where the repo has one, shown only when this Titan has one; the commit and the push are that workflow's, so a dirty tree does not hide it.
  • ⤓ Stash (only while the tree is dirty) puts the uncommitted work aside, new untracked files included, so the tree ends up clean. The stashes are the workspace's Stashes tab: pressing one shows its changes on the right as file cards, like a commit's, under a Stash card with Apply, keep it, Pop: apply and remove and Drop… (behind a second press); a popped or dropped stash sends the screen back to the uncommitted changes. The changes shown are those to tracked files; files stashed as untracked are not previewed. If git refuses a pop (a conflict, say) it says so and keeps the stash. In the pane, ⤒ Stashes (N) opens the workspace on the newest.
  • + Branch — a field for the name, ✦ Suggest with AI (reads the uncommitted diff under the prefixes this repo names its branches with, and, where the github plugin is installed, the labels its pull requests carry) and Create <name> and switch, the only thing that creates anything: a suggestion just fills the field. The name is put in the shape git accepts and judged before git is asked. The new branch starts at the branch you are on and carries the uncommitted work with it, so it is offered with a dirty tree too — the way out of having worked on the wrong branch.
  • ⇄ Merge — a picker led by the project's configured base branch, which runs the merge_workflow; it needs a clean tree.

Options ([mods.git.options] in ~/.titan/config.toml): repo_refresh_seconds (30), branches_refresh_seconds (60), refresh_key (f5, empty for none), recent_branches (8), commit_workflow (commit-ai), create_pr_workflow (create-pr-ai), merge_workflow (merge-branch), suggestion_diff_chars (4000).

Workspace

The plugin also ships the git workspace: a full screen opened from the Git dock tile (Esc goes back), a gitk for Titan. A top bar shows the branch, how it stands (↑ahead ↓behind) and ● uncommitted changes when the tree is dirty; it holds no buttons. The left column opens with the branch's toolbar. A selector with the branch you are on (⎇ feat/x ▾) unfolds the switcher: under the same large search field as the GitHub and Jira workspaces (✕ Clear search empties it) the branches you worked on most recently (reflog first, then last commit date); pressing one checks it out, typing searches every branch a checkout reaches (remote-only ones marked · remote) and Enter switches to the branch the text names, exactly or as the only branch containing it. With uncommitted work the panel says to commit or stash instead of listing branches. Under it a row with every action on the branch: ✦ Commit (only while the tree is dirty, runs commit_workflow), ⇩ Pull and ⇧ Push with how far behind or ahead the branch is, ⬈ PR (create_pr_workflow), ⤓ Stash (only while the tree is dirty), + Branch (a new branch from this one, with the AI's suggestion) and ⇄ Merge (a branch into this one; needs a clean tree). The last two open their panel under the toolbar. The row is drawn for the width of the column: the actions that do not fit, last ones first, are grouped behind ⋯, which unfolds them as a menu. The toolbar is one card (yellow while there are uncommitted changes). They use the same workflows and AI task as the mod's pane; while a pull, a push or a stash runs the row says what it is doing. Under the toolbar, three tabs show one thing at a time: History (the one it opens on), Stashes (N) and Worktrees (N). History is the commit graph (every branch and tag, always drawn as a graph; a tag is yellow, a remote branch blue and a local branch green) led by Uncommitted changes, in a card; + Show more adds commits_shown commits and - Show less takes one page back. Stashes lists them, newest first, Clear stash list… behind a second press. Worktrees lists every worktree; one unfolds into its path and a two-press removal (the main worktree and the one Titan runs in are refused), a forced removal is offered only after git has refused one, and Prune stale records clears what git keeps for folders deleted by hand. The files of what you pick sit on the right (the two stack when the window is narrow; drag the border between them to give either more room, and the width is remembered). Uncommitted changes list Staged and Unstaged files apart, new files included; a commit lists the files it changed, compared with its first parent when it is a merge. Each file is a card titled by its file name followed by its folder in dim (cut from the start when long; the whole path shows under the title when unfolded) that folds into its diff, drawn as code: line numbers, a bar and a tinted background on added and removed lines, syntax colours by file extension, and a sideways scroll for long lines. The first file of a selection opens on its own; a diff shows diff_lines lines and "+ Show more lines" adds that many again. History and uncommitted files are read again every refresh_seconds, when a workflow ends and with the refresh key; the open diffs of uncommitted files are read again with them. Options ([workspaces.git.options] in ~/.titan/config.toml): refresh_seconds (30), refresh_key (empty by default: the mod binds f5), commits_shown (40), context_lines (3), diff_lines (200). recent_branches, commit_workflow, create_pr_workflow, merge_workflow and suggestion_diff_chars are the mod's, shared: set them once in [mods.git.options]. The AI tasks (Branch name suggestion, Fix git error with AI) are the mod's too: one pin serves both. The mod's Open Git workspace button opens it. The workspace reads through get_commit_files, get_commit_file_diff, get_uncommitted_files and get_worktree_file_diff (see Client API).

Accessing the client

In Titan code, the public entry point is the Git plugin client:

git_plugin = config.registry.get_plugin("git")
client = git_plugin.get_client()

The client returns ClientResult[...] values. In practice, this means each call can succeed with data or return an error result.

Public workflow steps

The Git plugin exposes these reusable public steps through get_steps():

  • get_status
  • create_commit
  • push
  • get_current_branch
  • get_base_branch
  • ai_generate_commit_message
  • show_uncommitted_diff_summary
  • show_branch_diff_summary
  • save_current_branch
  • restore_original_branch
  • checkout
  • pull
  • create_branch
  • resolve_merge_target
  • fetch_merge_source
  • merge_source_branch
  • complete_merge
  • create_worktree
  • remove_worktree
  • worktree_commit
  • worktree_push

These steps are intended for workflow authors. Their inputs, outputs, and return behavior are documented in Workflow Steps.