Back to Blog
August 10, 2026

Running Parallel GitHub Copilot Agent Sessions with tmux and Git Worktrees

Share

Running Parallel GitHub Copilot Agent Sessions with tmux and Git Worktrees

Date: 2026-08-10

Run multiple GitHub Copilot CLI agents in parallel using tmux and git worktrees for isolated, persistent workspaces.

Tags: ["GitHub", "Productivity", "tmux", "Git Worktrees"]

Running Parallel GitHub Copilot Agent Sessions with tmux and Git Worktrees

When working with GitHub Copilot CLI, managing parallel coding sessions quickly becomes a challenge, especially as project scope grows and demands increase. Running multiple agents simultaneously can create conflict, clutter, and confusion, particularly when agents step on each other's changes within the same repository.

This article explores a practical solution: combining the power of tmux, a terminal multiplexer, with git worktrees, which provide isolated checkouts of branches in separate directories. Together, they let you run multiple Copilot agents in parallel without interference—each in its own persistent, isolated workspace. Beyond simply running agents side-by-side, this technique encourages better workflow organization, session persistence across disconnects, and safer multi-feature development.

You'll learn the rationale and practical steps to set up tmux sessions paired with git worktrees, how to coordinate multiple Copilot CLI agents across these workspaces, and how to review and merge your changes efficiently. Screenshots and command snippets illustrate the process in the context of building API endpoints for a sports fixtures project, unlocking a scalable, agentic coding workflow you can adapt to your projects.

What is tmux?

tmux is a terminal multiplexer that allows you to create, access, and control any number of terminals from a single screen. Unlike just splitting the terminal or creating new tabs, tmux sessions persist across SSH disconnections or system reboots, preserving long-running Copilot agent tasks without interruption.

Why use tmux for agentic coding?

tmux's persistence model is particularly handy when agents are running long processes within a session. Each pane provides its own pseudo-terminal (PTY), isolating Copilot CLI agent processes from each other while allowing the user to monitor multiple coding agents simultaneously.

Running this on WSL2

On Windows, tmux runs through WSL2 since it doesn't run natively on Windows. GitHub Copilot CLI also runs on WSL2, making this setup seamless. Essential packages include git, tmux, curl, Node.js, GitHub CLI (gh), and Windows Terminal.

Some tmux basics

Start a new tmux session:

tmux new -s swarm

Inside tmux:

  • Split the window vertically: Ctrl+b %
  • Split the window horizontally: Ctrl+b "
  • Cycle through layouts: Ctrl+b space
  • Detach session: Ctrl+b d
  • List sessions: tmux ls
  • Reattach session: tmux attach -t <session-name>

Giving each agent its own workspace with git worktrees

Git worktrees allow you to check out multiple branches concurrently within isolated folders, sharing the same .git directory. This prevents destructive merge conflicts when multiple Copilot agents update code simultaneously.

Create worktrees per feature branch as sibling directories:

git worktree add -b feature/standings ../fixtures-standings
git worktree add -b feature/h2h ../fixtures-h2h
git worktree add -b feature/upcoming ../fixtures-upcoming

List current worktrees:

git worktree list

Running multiple Copilot agents in parallel with tmux

In your tmux session, create panes for each worktree and navigate each pane to a different worktree folder:

# Pane 1
cd ../fixtures-standings

# Pane 2
cd ../fixtures-h2h

# Pane 3
cd ../fixtures-upcoming

Initiate Copilot CLI agents with tailored prompts and allow autonomous tooling:

# Pane 1: Standings endpoint
copilot --allow-all-tools -i "Add Endpoints/StandingsEndpoints.cs implementing IEndpointModule (see Endpoints/IEndpointModule.cs), mapping GET /table that returns FixtureData.Standings ordered by position. Inject FixtureData via constructor. New file only; do not edit Program.cs. Ensure build."

# Pane 2: Head-to-head endpoint
copilot --allow-all-tools -i "Add Endpoints/HeadToHeadEndpoints.cs implementing IEndpointModule mapping GET /fixtures/h2h?teamA=&teamB= returning matches between the two teams. Inject FixtureData. New file only; do not edit Program.cs. Ensure build."

# Pane 3: Upcoming fixtures endpoint
copilot --allow-all-tools -i "Add Endpoints/UpcomingEndpoints.cs implementing IEndpointModule mapping GET /fixtures/upcoming optional ?team= filter returning unplayed matches ordered by matchday. Inject FixtureData. New file only; do not edit Program.cs. Ensure build."

Detach if needed (Ctrl+b d) and reattach later with:

tmux attach -t swarm

Reviewing, merging, and cleaning up

Commit changes within each worktree and push branches:

git push -u origin feature/standings feature/h2h feature/upcoming

Create pull requests using gh CLI for each feature branch:

gh pr create --base main --head feature/standings --title "feat: add GET /table standings endpoint" --body "Adds Endpoints/StandingsEndpoints.cs mapping GET /table..."

gh pr create --base main --head feature/h2h --title "feat: add GET /fixtures/h2h endpoint" --body "Adds Endpoints/HeadToHeadEndpoints.cs mapping GET /fixtures/h2h..."

gh pr create --base main --head feature/upcoming --title "feat: add GET /fixtures/upcoming endpoint" --body "Adds Endpoints/UpcomingEndpoints.cs mapping GET /fixtures/upcoming..."

Check open PRs:

gh pr list

Merge the PRs with squash commits:

gh pr merge feature/standings --squash
gh pr merge feature/h2h --squash
gh pr merge feature/upcoming --squash

Update your local main branch and build:

git checkout main
git pull
dotnet build

Clean up the worktrees:

git worktree remove ../fixtures-standings
git worktree remove ../fixtures-h2h
git worktree remove ../fixtures-upcoming
git worktree prune

git branch -d feature/standings feature/h2h feature/upcoming
git push origin --delete feature/standings feature/h2h feature/upcoming

Quick tips & tricks

  1. Use tmux for persistent CLI sessions to keep Copilot agents running uninterrupted.
  2. Leverage git worktrees to isolate features and avoid merge conflicts.
  3. Automate PR management with gh CLI.
  4. Run Copilot CLI with --allow-all-tools for autonomy.
  5. Split tmux panes for real-time monitoring.
  6. Maintain guardrails and human review to ensure code quality.

Conclusion

Combining tmux and git worktrees offers an effective way to run multiple GitHub Copilot CLI agents in parallel, each in isolated, persistent workspaces. This setup avoids overwrite conflicts, enables easy monitoring of multiple coding agents, and integrates smoothly with GitHub's PR workflow through the CLI.

This approach scales well as agent-assisted development grows, providing fundamental building blocks for more advanced multi-agent orchestration and collaboration. By embracing these tools, engineers can harness Copilot efficiently while maintaining control and code quality.

References

  1. Running parallel GitHub Copilot agent sessions with tmux and git worktrees - DEV Community — Original article by Will Velida.
  2. tmux - Official documentation
  3. Git worktree - Git SCM docs
  4. GitHub Copilot CLI docs