Automatically Syncing Files with Your Workspace
Keep files in sync between your local development environment and your workspace so you can edit locally and run remotely.
Mutagen (Recommended)
Section titled “Mutagen (Recommended)”Mutagen provides real-time, bidirectional file synchronization with excellent performance. It handles large projects efficiently, detects conflicts, and works across macOS, Linux, and Windows.
Installation
Section titled “Installation”# macOSbrew install mutagen-io/mutagen/mutagen
# Windows (via Scoop)scoop install mutagenSee mutagen.io/documentation/introduction/installation for other platforms.
Creating a Sync Session
Section titled “Creating a Sync Session”mutagen sync create ~/local/project wsm.my_workspace:/home/web/html \ --ignore=.git \ --ignore=node_modules \ --ignore=vendorThis starts a persistent background session that watches for changes on both sides and syncs them automatically.
Managing Sessions
Section titled “Managing Sessions”# List active sessionsmutagen sync list
# Monitor sync status in real timemutagen sync monitor
# Pause a sessionmutagen sync pause --all
# Resume a sessionmutagen sync resume --all
# Terminate a sessionmutagen sync terminate --allConfiguration File
Section titled “Configuration File”For repeatable setups, create a mutagen.yml in your project root:
sync: defaults: ignore: paths: - ".git" - "node_modules" - "vendor" - "*.log" workspace: alpha: "." beta: "wsm.my_workspace:/home/web/html" mode: "two-way-resolved"Then start with:
mutagen project startSync Modes
Section titled “Sync Modes”two-way-safe(default) — Syncs both directions, flags conflicts for manual resolutiontwo-way-resolved— Syncs both directions, alpha (local) wins on conflictone-way-safe— Local → remote only, won’t overwrite remote changes not yet synced backone-way-replica— Local → remote only, remote is an exact mirror
For most development workflows, two-way-resolved works well — your local edits take priority.
rsync is a simpler alternative for one-way synchronization or scripted workflows.
Basic Usage
Section titled “Basic Usage”# Push local changes to workspacersync -avz --progress ~/local/project/ wsm.my_workspace:/home/web/html/
# Pull workspace changes to localrsync -avz --progress wsm.my_workspace:/home/web/html/ ~/local/project/Automatic Sync with File Watching
Section titled “Automatic Sync with File Watching”macOS (fswatch)
Section titled “macOS (fswatch)”brew install fswatch#!/bin/bashPROJECT_DIR="$HOME/local/project"WORKSPACE="wsm.my_workspace:/home/web/html/"
fswatch -o "$PROJECT_DIR" | while read f; do rsync -avz --delete \ --exclude '.git' \ --exclude 'node_modules' \ --exclude 'vendor' \ "$PROJECT_DIR/" "$WORKSPACE"doneLinux (inotifywait)
Section titled “Linux (inotifywait)”#!/bin/bashPROJECT_DIR="$HOME/local/project"WORKSPACE="wsm.my_workspace:/home/web/html/"
while inotifywait -r -e modify,create,delete,move "$PROJECT_DIR"; do rsync -avz --delete \ --exclude '.git' \ --exclude 'node_modules' \ --exclude 'vendor' \ "$PROJECT_DIR/" "$WORKSPACE"doneExcluding Files
Section titled “Excluding Files”Use an exclude file (similar to .gitignore):
.gitnode_modulesvendor*.log.env.DS_Storersync -avz --exclude-from='.rsyncignore' \ ~/local/project/ wsm.my_workspace:/home/web/html/Or leverage your existing .gitignore:
rsync -avz --filter=':- .gitignore' \ ~/local/project/ wsm.my_workspace:/home/web/html/Choosing Between Mutagen and rsync
Section titled “Choosing Between Mutagen and rsync”| Mutagen | rsync | |
|---|---|---|
| Direction | Bidirectional | One-way per invocation |
| Real-time | Yes (background daemon) | Requires file watcher script |
| Conflict handling | Built-in resolution | Manual |
| Performance | Optimized for large trees | Good, but re-scans on each run |
| Setup | One command | Script required for automation |
Use Mutagen for day-to-day development. Use rsync for one-off transfers, CI scripts, or environments where you can’t install Mutagen.
Related Documentation
Section titled “Related Documentation”- SSH Access – Configure SSH access to workspaces
- Connecting JetBrains IDEs – Use JetBrains built-in sync
- Connecting Visual Studio Code – Use VS Code Remote-SSH