Introducing Workspace Git Foundation: Never Lose Context When Switching Branches Again

Mar 18, 2026

TL;DR: Refresh Agents now supports Workspace Git Foundation — isolated Git environments that let you work on multiple features simultaneously without git stash, context switching pain, or losing uncommitted work.


The Problem: Git Context Switching is Painful

Every developer has experienced this frustration:

# You're deep in feature work with uncommitted changes
$ git status
Modified: src/auth.ts (50 lines changed)
Modified: src/api.ts (30 lines changed)

# Suddenly: urgent bug fix needed on main branch
$ git checkout main
error: Your local changes would be overwritten by checkout.
Please commit your changes or stash them before you switch branches.

# The tedious dance begins...
$ git stash
$ git checkout main
$ git checkout -b hotfix/urgent-bug
# ... fix the bug ...
$ git checkout feature-branch
$ git stash pop
# ... hope nothing conflicts ...

This workflow is broken. You lose mental context, risk merge conflicts, and waste time managing stashes.


The Solution: Workspace Git Foundation

With Workspace Git Foundation, each chat in Refresh Agents gets its own isolated Git workspace:

Chat A → Workspace A → feature/authentication
  ├─ Branch: feature/authentication
  ├─ Worktree: .worktrees/workspace-a/
  └─ State: 3 uncommitted files, 2 commits ahead

Chat B → Workspace B → feature/dashboard
  ├─ Branch: feature/dashboard
  ├─ Worktree: .worktrees/workspace-b/
  └─ State: Clean, 5 commits ahead, PR #42 open

Chat C → Workspace C → hotfix/urgent-bug
  ├─ Branch: hotfix/urgent-bug
  ├─ Worktree: .worktrees/workspace-c/
  └─ State: 1 commit, ready to merge

No more git stash. No more context switching. No more lost work.


How It Works

1. Automatic Workspace Creation

When you create a new chat:

  1. Refresh automatically creates a dedicated Git branch
  2. Creates a separate worktree in .worktrees/ directory
  3. Tracks branch status, PR state, and conflicts independently

2. Physical Directory Isolation

Each workspace has its own physical directory:

your-project/
├── .git/                    # Main repo
├── src/                     # Main branch files
└── .worktrees/
    ├── workspace-a/         # Chat A's isolated directory
    │   └── src/             # Independent file state
    ├── workspace-b/         # Chat B's isolated directory
    │   └── src/             # Different file state
    └── workspace-c/         # Chat C's isolated directory
        └── src/             # Yet another file state

Switch between chats = switch between workspaces. No git checkout needed.

3. Smart Recommendations

Refresh analyzes your workspace state and recommends the next action:

  • Uncommitted changes? → "Commit Changes"
  • Ahead of remote? → "Push to Remote"
  • Behind target branch? → "Sync with Main"
  • Ready to deliver? → "Create Pull Request"
  • Conflicts detected? → "Resolve Conflicts"

No more guessing what to do next.

4. Auto-Recovery

Accidentally deleted the worktree directory? No problem.

Refresh detects missing workspaces and offers one-click recovery:

⚠️ Workspace Missing
Your workspace directory was deleted or moved.

[Recover Workspace] [Archive Chat]

Click "Recover" and Refresh recreates the worktree from your branch.


Real-World Use Cases

Use Case 1: Parallel Feature Development

Scenario: You're building authentication (Chat A) when your PM asks you to prototype a dashboard (Chat B).

Traditional Git:

$ git stash                    # Save auth work
$ git checkout -b dashboard    # New branch
# ... work on dashboard ...
$ git checkout auth-branch     # Back to auth
$ git stash pop                # Restore auth work

With Workspaces:

  1. Create Chat B → Workspace B auto-created
  2. Work on dashboard in Chat B
  3. Switch back to Chat A → Auth work still there, untouched

Time saved: ~5 minutes per context switch × 10 switches/day = 50 minutes/day

Use Case 2: Hotfix Without Losing Work

Scenario: You have 50 uncommitted lines in a feature branch. Production bug needs immediate fix.

Traditional Git:

$ git stash                    # Pray nothing breaks
$ git checkout main
$ git checkout -b hotfix
# ... fix bug ...
$ git checkout feature
$ git stash pop                # Hope for no conflicts

With Workspaces:

  1. Create Chat C for hotfix → New workspace auto-created
  2. Fix bug in Chat C
  3. Switch back to Chat A → Your 50 uncommitted lines are still there

Stress level: 📉 Zero anxiety

Use Case 3: Code Review Without Disruption

Scenario: You're reviewing a PR while working on your feature.

Traditional Git:

$ git stash
$ git fetch origin pull/123/head:pr-123
$ git checkout pr-123
# ... review code ...
$ git checkout feature
$ git stash pop

With Workspaces:

  1. Create Chat D for PR review → Workspace D auto-created
  2. Review code in Chat D
  3. Switch back to Chat A → Feature work untouched

Multi-Repo Support

Working on a monorepo or multi-repo project? Workspaces support multiple repositories in a single workspace:

Workspace A
├─ Repo: frontend (feature/new-ui)
├─ Repo: backend (feature/new-api)
└─ Repo: shared (feature/types)

All repos stay in sync within the same workspace. No more juggling multiple terminal windows.


Performance & Cleanup

Automatic Garbage Collection

Workspaces are automatically cleaned up after 72 hours of inactivity:

  • Active workspaces: Kept indefinitely
  • Pinned workspaces: Kept for 7 days
  • Archived workspaces: Cleaned up after 1 hour

Disk Space

Worktrees use hard links for unchanged files, so disk usage is minimal:

  • Main repo: 500 MB
  • 3 worktrees: +50 MB (only changed files)

Architecture Highlights

For the technically curious, here's what makes Workspace Git Foundation robust:

1. State Machine Design

Workspace lifecycle is managed by a state machine:

creating → ready → missing → recovered

              failed → retry

2. Snapshot + Live Inspection

  • Snapshot: Cached branch status for fast UI updates
  • Live Inspection: Real-time Git status when you open a chat

3. Conflict Detection

Refresh detects conflicts during:

  • Rebase operations
  • Merge operations
  • Cherry-pick operations

And provides one-click resolution UI.


Getting Started

Step 1: Update to Latest Version

# macOS
brew upgrade refresh-agents

# Or download from
https://refresh-agents.com/download

Step 2: Create a New Chat

  1. Open Refresh Agents
  2. Click "New Chat"
  3. Select your project folder

That's it. Your first workspace is created automatically.

Step 3: Explore the Workspace Status Bar

At the top of your chat, you'll see:

🌿 feature/chat-abc123  │  ↑2 ↓1 ●3  │  PR #42
  • 🌿 Branch name
  • ↑2: 2 commits ahead
  • ↓1: 1 commit behind
  • ●3: 3 uncommitted files
  • PR #42: Associated pull request

What's Next?

We're just getting started. Here's what's coming:

  • Workspace Templates: Pre-configured setups for common workflows
  • Workspace Sharing: Share workspaces with teammates
  • Cloud Sync: Sync workspaces across devices
  • VS Code Integration: Open workspaces directly in VS Code

Try It Today

Workspace Git Foundation is available now in Refresh Agents v0.1.0+.


Feedback?

We'd love to hear how Workspace Git Foundation improves your workflow:


Never lose context again. Start using Workspace Git Foundation today. 🚀

Refresh Team

Refresh Team

Introducing Workspace Git Foundation: Never Lose Context When Switching Branches Again | Blog