Note -a is archive mode (preserves permissions, timestamps, symlinks). -v is verbose. -z compresses during transfer. --delete removes files from the destination that no longer exist in the source (be careful). Trailing slash on source matters: dir/ syncs contents, dir syncs the directory itself.
Note sync copies changed files into the container without rebuilding. rebuild triggers a full image rebuild when the specified file changes (e.g., when you add a dependency). This replaces many custom file-watching setups.
Frequently asked questions
How does Bash & Linux handle file sync?
This task is covered in 2 stacks on this page: Bash & Linux, Docker. The "Efficient File Synchronization" snippet in Bash & Linux uses `rsync [options] source destination`.
Which command does the Bash & Linux example use?
The "Efficient File Synchronization" snippet uses `rsync [options] source destination`, from the Networking section of the Bash & Linux cheat sheet.
Which stacks cover "file sync" on this page?
Bash & Linux, Docker. Together they hold 2 copy-ready snippets for this task.
Is there anything to watch out for?
Yes. For "Efficient File Synchronization": -a is archive mode (preserves permissions, timestamps, symlinks). -v is verbose. -z compresses during transfer. --delete removes files from the destination that no longer exist in the source (be careful). Trailing slash on source matters: dir/ syncs contents, dir syncs the directory itself.