Skip to main content

vers branch

Create a new VM from an existing VM or commit, inheriting its complete state.

Synopsis

Description

The branch command creates a new VM that inherits the complete state from an existing VM or commit. This allows you to continue from exactly where the source left off, but in a separate environment where you can make different changes. When branching from a running VM, the parent is briefly paused to create a consistent snapshot, then a new VM spawns from that commit and the parent automatically resumes. Both VMs end up running simultaneously. When branching from a commit ID, the new VM is created directly from that saved state.

Basic Usage

Create VM from Current HEAD

Creates a new VM from your current HEAD VM.

Create VM from Specific VM

Creates a new VM from the specified VM ID or alias.

Create VM with Custom Alias

Creates a new VM with a custom alias instead of just using the VM ID.

Options

--alias, -n

Assign a custom alias to the new VM:

--checkout, -c

Automatically switch your HEAD to the new VM after creation:

What Happens When You Branch

When branching from a VM:
  1. Parent Pauses: The source VM is briefly paused for a consistent snapshot
  2. Commit: The source VM’s current state is committed
  3. VM Creation: A new VM is spawned from that commit with a unique VM ID
  4. Parent Resumes: The source VM automatically resumes
  5. Both Run: Both parent and child VMs end up running simultaneously
  6. Optional Aliasing: If --alias is provided, the new VM gets a friendly name
  7. Optional Checkout: If --checkout is used, your HEAD pointer switches to the new VM
When branching from a commit ID:
  1. VM Creation: A new VM is spawned directly from the specified commit
  2. Optional Aliasing/Checkout: Same as above

Examples

Basic VM Creation

Creating and Switching

Creating from Specific VM

Creating from a Commit

The commit ID is automatically detected - if the ID doesn’t match an existing VM, it’s treated as a commit ID.

Understanding Branch Output

When you create a VM, you’ll see output like:
This shows:
  • Which VM was used as the source
  • The new VM’s ID and alias (if provided)
  • The current state of the new VM
  • Instructions for switching to the new VM

Common Workflows

Experimentation

Parallel Development

Tips

  • If you don’t specify --alias, the new VM will only be accessible by its VM ID
  • Aliases are stored locally at ~/.vers/aliases.json - they don’t sync between machines
  • Use --checkout when you want to immediately start working on the new VM
  • The parent VM remains unchanged and accessible

Common Patterns

Fan out N parallel workers

Branch a prepared VM into N isolated copies — agent swarms, parallel tests, scenario exploration:

Branch and switch in one step

Branch from a tag or commit, not a live VM

Explore and discard

See Also