Skip to main content

vers commit

Save the current state of a VM as a commit with optional tagging.

Synopsis

vers commit                          # Commit current HEAD VM
vers commit <vm-id|alias>           # Commit specific VM
vers commit --tag v1.0              # Commit with single tag
vers commit --tag v1.0 --tag stable # Commit with multiple tags
vers commit --tags "v1.0,stable"    # Commit with comma-separated tags

Description

The commit command creates a snapshot of a VM’s current state by saving it as a commit. This preserves the exact state of the VM at a specific point in time. You can commit either your current HEAD VM or specify a particular VM by ID or alias.

Basic Usage

Commit Current HEAD VM

vers commit
Creates a commit of whatever VM your HEAD currently points to.

Commit Specific VM

vers commit vm-abc123
vers commit my-app-vm
Creates a commit of the specified VM by ID or alias.

Tagging Commits

Single Tag

vers commit --tag v1.0.0
vers commit my-vm --tag production-ready

Multiple Tags (Repeated Flag)

vers commit --tag v1.0 --tag stable --tag release

Multiple Tags (Comma-Separated)

vers commit --tags "v1.0,stable,release"
vers commit my-vm --tags "feature-complete,tested"

Combining Both Flag Types

vers commit --tag primary --tags "v1.0,stable"
# Results in tags: primary, v1.0, stable

What Happens During Commit

  1. VM Identification: Resolves the target VM (provided or HEAD)
  2. Tag Processing: Combines all tags from both flag types
  3. State Capture: Creates a snapshot of the VM’s current state
  4. Commit Creation: Saves the commit via the API with a 60-second timeout

Examples

Development Workflow

# Commit current work in progress
vers commit --tag "wip-auth-feature"

# Commit specific VM after testing
vers commit test-vm --tag "tests-passing"

# Commit with version and status tags
vers commit --tag v2.1.0 --tag stable

Release Process

# Mark release candidate
vers commit production-vm --tags "v1.0-rc1,release-candidate"

# Final production commit
vers commit production-vm --tag v1.0 --tag production --tag stable

Multiple Environment Commits

# Commit development environment
vers commit dev-env --tag "feature-complete"

# Commit staging environment  
vers commit staging-env --tag "qa-approved"

# Commit production environment
vers commit prod-env --tag "v2.0-release"

Commit Output

When you commit, you’ll see detailed information:
vers commit my-app --tag v1.0 --tag stable
Using provided VM: my-app
Creating commit for VM 'vm-abc123'
Tags: v1.0, stable
Creating commit...
Successfully committed VM 'my-app'
Commit ID: c1a2b3c4d5e6f7g8
Cluster ID: cluster-xyz789
Host Architecture: x86_64
Tags: v1.0, stable
The output includes:
  • Commit ID: Unique identifier for this commit
  • Cluster ID: The cluster containing the VM
  • Host Architecture: System architecture (e.g., x86_64, arm64)
  • Tags: All applied tags

Using HEAD VM

When no VM is specified, the command uses your current HEAD:
# Check your current HEAD
vers checkout
Current HEAD: my-dev-vm (State: Running)

# Commit it
vers commit --tag milestone-1
Using current HEAD VM: vm-def456
Creating commit for VM 'vm-def456'
...

Error Scenarios

VM Not Found

vers commit nonexistent-vm --tag v1.0
# Error: failed to find VM: VM not found
Solution: Verify the VM ID/alias exists with vers status or vers tree.

No HEAD Set

vers commit
# Error: failed to get current VM: no HEAD set
Solution: Use vers checkout <vm-id> to set a HEAD, or specify a VM explicitly.

Timeout

vers commit large-vm --tag backup
# Error: failed to commit VM 'large-vm': context deadline exceeded
Solution: Commit operations have a 60-second timeout. Try again or check your network connection.

Flags

--tag, -t

Add individual tags to the commit. Can be repeated multiple times:
vers commit --tag v1.0 --tag stable --tag release

--tags

Add multiple tags as a comma-separated list:
vers commit --tags "v1.0,stable,release"
Note: You can use both flag types in the same command - all tags will be combined.

Tag Best Practices

  • Version tags: v1.0.0, v2.1-beta
  • Status tags: stable, testing, production
  • Feature tags: auth-complete, ui-redesign
  • Environment tags: dev, staging, prod
  • Date tags: 2024-01-15, weekly-backup

Common Patterns

Milestone Commits

# Feature development milestones
vers commit --tag "auth-module-complete"
vers commit --tag "testing-phase-done"
vers commit --tag "ready-for-review"

Environment Promotion

# Commit in dev, then promote to staging
vers commit dev-vm --tags "dev-complete,ready-for-staging"

# Later commit the staging version
vers commit staging-vm --tags "staging-verified,ready-for-prod"

Backup Strategy

# Daily backups with dates
vers commit --tag "backup-$(date +%Y-%m-%d)"

# Weekly stable snapshots
vers commit --tags "weekly-backup,stable,$(date +%Y-week-%U)"

Tips

  • Use descriptive tags that explain the purpose of the commit
  • Combine version numbers with status tags for clarity
  • Commit before making risky changes to preserve known-good states
  • Tags help you identify important snapshots later

See Also