Skip to content

shell: add --sync-exclude flag to exclude paths from --sync#5077

Open
itsme-ranger wants to merge 1 commit into
lima-vm:masterfrom
itsme-ranger:feat/shell-sync-exclude
Open

shell: add --sync-exclude flag to exclude paths from --sync#5077
itsme-ranger wants to merge 1 commit into
lima-vm:masterfrom
itsme-ranger:feat/shell-sync-exclude

Conversation

@itsme-ranger
Copy link
Copy Markdown

Fixes #4887

Changes

Adds a --sync-exclude flag to limactl shell --sync that passes --exclude to all rsync operations (host→guest initial sync, the dry-run stats pass, and the guest→host sync-back).

# Exclude node_modules and .git from the sync
limactl shell --sync . --sync-exclude=node_modules --sync-exclude=.git default

# Use rsync glob patterns
limactl shell --sync . --sync-exclude='*.o' --sync-exclude=dist myinstance

The flag uses rsync's standard --exclude syntax and can be specified multiple times. Using --sync-exclude without --sync returns an error.

Implementation

  • Added --sync-exclude as a StringArray flag on the shell command
  • Built excludeArgs as ["--exclude", val, ...] pairs
  • Threaded into the copytool.Options.AdditionalArgs of the initial sync CopyTool (which is also reused for rsync-back and the "view changes" diff)
  • Added excludeArgs parameter to getRsyncStats so the dry-run stats pass applies the same filters

Testing

  • go build ./cmd/limactl/ passes
  • go test ./cmd/limactl/... passes
  • golangci-lint run ./cmd/limactl/... reports 0 issues

Closes lima-vm#4887

Signed-off-by: Ramadhan Gerry Akbar <ramadhan.gerry@gmail.com>
@itsme-ranger itsme-ranger force-pushed the feat/shell-sync-exclude branch from 7626689 to f54bc52 Compare June 3, 2026 07:25
@unsuman unsuman added the duplicate This issue or pull request already exists label Jun 4, 2026
@unsuman
Copy link
Copy Markdown
Member

unsuman commented Jun 4, 2026

Seems duplicate of #4917

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

duplicate This issue or pull request already exists

Projects

None yet

Development

Successfully merging this pull request may close these issues.

shell --sync: Allow excluding files/folders from rsync

2 participants