Inject a file with --file
Use --file / -F on contree run to attach a local file:
- CLI
- Shell
Full --file syntax
- host_path – path to the file on your machine (required)
- instance_path – destination path inside the sandbox (detected by
leading
/). Defaults to the host path. - uUID – owner UID (prefix
u). Numeric or name (resolved locally). - gGID – group GID (prefix
g). Numeric or name (resolved locally). - mMODE – octal permission mode (prefix
m).
u, g, m) can appear in any order after the host
path. Unspecified values default to the host file’s stat.
Named uid/gid (e.g.
uroot) are resolved locally via pwd/grp
modules. Use numeric IDs if unsure about host/instance mismatch.Multiple files
Repeat the--file flag:
Directories
--file also accepts directories. The entire tree is uploaded recursively:
.*, .git, *.pyc, __pycache__,
.venv, .mypy_cache, .pytest_cache, node_modules, dist, build.
Add extra exclusions with --file-excludes:
Upload caching
The CLI keeps a local upload cache keyed by file path, inode, modification time, and size. Repeated attachments of unchanged files skip both the hash calculation and the API call. The cache expires after 90 days to account for server-side file retention. The server also deduplicates by SHA256 — if the same content was uploaded from a different session or machine, it is reused without re-uploading.Edit remote files
- CLI
- Shell
contree file edit downloads a file from the session image, opens it
in your $EDITOR, and stages the changes as a pending file:- The file is downloaded from the current session image to a temp file
- Your editor opens (
$EDITOR, defaults tovi) - If you saved changes, the modified file is uploaded and staged as pending
- If the file is unchanged (same SHA256), nothing is staged
Iterate without re-running
You can edit multiple files before running:Stage local files with contree file cp
contree file cp copies a local file into the session as a pending file:
contree run automatically.
Build up a working environment
run consumes all three pending files and bakes them into the
new image. The second run already has them – no re-upload needed.
How pending files work
Pending files accumulate until the nextcontree run:
- Each
file editorfile cprecords a pending file in the session - When you run
contree run, all pending files are merged into the payload - After the run completes, the new image already contains those files
- The pending queue is effectively cleared (a new history checkpoint is created past them)
--file flags on contree run take priority over pending files
at the same path.
Pending files are branch-aware – switching branches with
contree session checkout changes which pending files are visible.
Deduplication
Files are uploaded to the API with SHA256 dedup. If the same file content has already been uploaded (from a previous edit or a different session), it is reused without re-uploading.You can inject and edit files. Next: Images & Tags.