Salesforce CLI
sf project deploy: deploy only changed files
Use git to diff against main and pass the changed files to `sf project deploy start`. Cuts deploy times from minutes to seconds in large repos.
# Deploy only metadata that changed vs the main branch.
git fetch origin main
git diff --name-only --diff-filter=ACMR origin/main...HEAD \
-- 'force-app/**' \
| xargs -I {} sf project deploy start --source-dir {}
# To preview without deploying:
git diff --name-only --diff-filter=ACMR origin/main...HEAD -- 'force-app/**'Notes
- Pair with --test-level RunSpecifiedTests to skip the full Apex test suite for tiny changes.
- Add `xargs -P 4` for parallel deploys when each batch is independent.