Git Integration
Copair integrates with git to manage your workflow — creating branches, making commits with meaningful messages, and reviewing diffs.
Current branch in the status bar
When you launch Copair inside a git repo, the active branch appears in green next to the model name in both the Ink status bar and the legacy REPL prompt:
claude-4-sonnet (feat/jwt-auth) | 8.9K tokens | [████████░░] 78% | ~$0.12The branch refreshes after every turn — if Copair (or you) runs git checkout mid-session, the next prompt reflects the new branch. Detached-HEAD state is shown as (HEAD detached). Outside a git repository, the branch field is omitted.
Automatic Branch Creation
When Copair starts making changes, it can create a feature branch automatically:
> Add user authentication with JWT tokens
Creating branch: feat/add-jwt-auth
Switched to new branch 'feat/add-jwt-auth'This keeps your main branch clean and makes it easy to review changes before merging.
Meaningful Commit Messages
Copair generates commit messages that describe what was changed and why:
> Fix the race condition in the connection pool
Committed: fix(pool): prevent concurrent access to shared connection map
Uses sync.Mutex to guard the connections map in ConnectionPool.Get()
and ConnectionPool.Release(), preventing the data race reported in #142.Commit messages follow the Conventional Commits format by default.
Diff Review
Copair shows you diffs before committing, so you can review exactly what changed:
--- a/src/pool.ts
+++ b/src/pool.ts
@@ -15,6 +15,8 @@ export class ConnectionPool {
+ private mutex = new Mutex()
+
async get(): Promise<Connection> {
+ await this.mutex.acquire()
const conn = this.connections.get(this.nextId)You can approve, modify, or reject changes before they're committed.
Git Commands
Copair has a built-in Git tool that can:
- Read —
git status,git log,git diff,git blame - Write —
git add,git commit,git checkout -b - Review — Show structured diffs with syntax highlighting
Workflow Example
A typical git-integrated workflow:
> Refactor the API routes to use the new middleware pattern
1. Creating branch: refactor/api-middleware
2. Reading current route files...
3. Implementing middleware pattern...
4. Running tests...
5. All tests pass.
Ready to commit:
Modified: src/routes/users.ts
Modified: src/routes/posts.ts
Modified: src/middleware/auth.ts
Added: src/middleware/validate.ts
Commit message: refactor(api): migrate routes to middleware pattern
Proceed? [y/n]Co-Author Identity
Copair automatically appends a Co-authored-by: trailer to all git commits, so you can track which changes were AI-assisted:
feat(auth): add JWT token validation
Implement token validation middleware with expiry checking
and role-based access control.
Co-authored-by: Copair <copair[bot]@noreply.dugleelabs.io>Default Identity
Out of the box, commits are co-authored as:
Copair <copair[bot]@noreply.dugleelabs.io>Custom Identity
Configure the co-author name and email in your config:
# ~/.copair/config.yaml
identity:
name: "Copair"
email: "copair[bot]@noreply.dugleelabs.io"Linking to GitHub
To link the co-author to a real GitHub profile, use a GitHub noreply email:
identity:
name: "copair-bot"
email: "[email protected]"This makes the co-author avatar and profile link appear on commits in the GitHub UI.
Configuration
Git behavior is controlled through natural language instructions in your prompt or via COPAIR_KNOWLEDGE.md. For example, you can tell Copair:
> Don't create branches automatically, I'll manage them myself
> Use simple commit messages instead of conventional commits
> Stage changes but let me review before committing
You can also add persistent instructions to your project's COPAIR_KNOWLEDGE.md:
## Git conventions
- Do not create feature branches automatically
- Use conventional commit format
- Always show diffs before committing