feat(git): extend source control with worktrees, stashes, conflicts and identities

- Create a worktree from a new or existing branch
- Integrate a worktree branch into a target branch by merge commit or cherry-pick, with continue/abort on conflicts
- Delete a worktree with keep, delete-local, or delete-local-and-remote branch options, using safe branch deletion for unmerged branches
- Add a stash tab (list, push, apply, pop, drop) shared across a repository and its worktrees
- Rename and delete branches, optionally deleting the remote branch and updating scheduled base branches
- Detect in-progress merge, rebase, cherry-pick and revert operations and hand conflicts to an agent session
- Generate commit messages from staged changes with the default model
- Add a default git identity and saved per-repository identities written to git config
- Unify git error mapping behind a typed error and one route helper; consolidate git mutations and cache invalidation
- Update repository docs
This commit is contained in:
Chris Scott committed 2026-10-03 21:59:00 -04:00
1 parent 52b6147ed3
commit 53238a6324
89 files changed
+7704 -793

No files matched your search

+60 -2
View File
@@ -41,7 +41,7 @@ Work on multiple branches simultaneously without switching:
1. Select a repository
2. Click **Create Worktree**
3. Enter branch name
3. Choose **New branch** (enter a name and pick a base branch) or **Existing branch** (pick a local or remote branch to check out)
4. A new workspace is created with that branch checked out
Worktrees share the same git history but have independent working directories. This is useful for:
@@ -50,6 +50,26 @@ Worktrees share the same git history but have independent working directories. T
- Working on a feature while keeping main branch accessible
- Testing changes without disrupting your main work
### Integrating a Worktree Branch
From a worktree's Branches tab, click **Integrate** to bring its commits into another branch:
1. Choose the target branch. It must be checked out cleanly in another managed worktree, with no uncommitted changes or operation already in progress.
2. Choose a strategy: **Merge commit** integrates all commits with a merge commit, while **Cherry-pick commits** replays each commit onto the target.
3. Click **Integrate**.
If the target stops on conflicts, the operation banner appears in the dialog so you can resolve, continue, or abort the integration.
### Deleting a Worktree
Deleting a worktree offers three branch options:
- **Keep branch** - Leave the branch in the parent repository.
- **Delete local branch** - Remove the branch from the parent repository.
- **Delete local and remote branch** - Also delete the branch from origin.
**Delete local branch** and **Delete local and remote branch** use a safe delete: if the branch has unmerged commits it is kept (and the remote branch is not deleted either), and a warning names it. Force-delete it from the Branches tab if intended.
## Source Control Panel
Access comprehensive git operations via the source control button.
@@ -77,10 +97,48 @@ Access comprehensive git operations via the source control button.
- List all local and remote branches
- Create new branches from current HEAD
- Switch branches (checks out the branch)
- Delete local branches
- Rename a local branch from its actions menu. Renaming also updates the base branch of schedules in every checkout of the same git repository that used the old name. A worktree's folder keeps the old branch name; `ocm` mirroring looks for a folder named after the new branch, so mirroring the renamed branch fails while that worktree exists.
- Delete local branches, optionally force-deleting an unmerged branch and, when the branch tracks a remote, also deleting the remote branch. The current branch and branches checked out in another worktree cannot be deleted.
![Branches Tab](../images/git/git-branch.png){ .phone }
### Stash Tab
Stash work in progress and restore it later:
- Enter an optional message and choose whether to include untracked files
- **Stash changes** saves the working tree and index
- Each stash shows its branch and date, with **Apply** (restore and keep the stash), **Pop** (restore and remove the stash), and **Drop** (delete the stash)
- The stash list is shared by a repository and all its worktrees. Apply, Pop, and Drop verify the stash is still the one shown and ask you to refresh if the list changed.
### Merge, Rebase and Cherry-pick Conflicts
When a merge, rebase, or cherry-pick stops on conflicts, an operation banner appears at the top of the source control panel:
- Shows the operation kind and the list of conflicted files
- **Continue** finishes the operation once every conflict is resolved
- **Abort** cancels the operation and restores the previous state
- **Resolve with agent** opens a new session in the repository, primed with the conflicted files, so an agent can resolve them
### Committing
Commit staged changes with a message. Press ⌘/Ctrl+Enter to commit without clicking the button.
#### AI Commit Messages
Use the sparkle button in the commit box to generate a commit message from the staged changes using OpenCode's default model. Only staged changes are used, and the generated message replaces the current text after confirmation.
#### Commit Identities
Configure identities in **Settings > Git**:
- **Default identity** - Written to Manager's own git config file (`.config/git/config` in the workspace). When the name or email is empty and a GitHub token credential is configured, the missing parts come from the GitHub account. It applies to Manager commits, agent shells, terminals, and scheduled runs without restarting OpenCode. Because it is a global-level git config file, a repository's own identity and, on non-Docker installs, your `~/.gitconfig` identity take precedence over it.
- **Saved identities** - Presets that can be applied to individual repositories.
Each repository has a **Commit as** selector in the commit box. Choosing a saved preset writes it into the repository's local git config (`user.name` / `user.email`), which git shares with all worktrees of the repository (Manager worktrees, OpenCode workspaces, and scheduled-run worktrees). Choosing **Default** removes the repository's local identity. An identity you set yourself in the repository's local git config is respected and shown as **Custom**; the selector asks before replacing it. The selector shows the effective identity and where it comes from (repository, Manager default, git global config, or not configured). Removing a saved preset does not change repositories that use it.
Sandboxed shells receive the resolved identity for their directory.
## Diff Viewer
View file changes with a unified diff format: