Intermediate 20 min read

Source-Driven Development with the CLI

By the end of this lesson, you'll be able to:

  • Push local source to a scratch org and pull org changes back to local source
  • Explain when to use deploy/retrieve versus a manifest-based deploy

Prerequisites: Scratch Orgs and sfdx-project.json

Deploy and retrieve

sf project deploy start --source-dir <path> pushes local source into an org. sf project retrieve start --source-dir <path> pulls org metadata back down into that same local folder. Both work against any authenticated org — scratch org, sandbox, or production — and both understand exactly which files changed.

A typical local development loop

The everyday rhythm looks like this: edit metadata locally in your IDE, deploy it to your scratch org to test it, and if you made a quick change directly in the org's UI (like adding a field through Setup), retrieve it back down to local source and commit it to Git.

Local source plus Git is the real source of truth — the org itself stays disposable.

Pushing and pulling force-app

sf project deploy start --source-dir force-app --target-org my-scratch
sf project retrieve start --source-dir force-app --target-org my-scratch

deploy start pushes your local force-app source into the target org; retrieve start pulls any changes made in that org back down into the same local folder.

Exercise

Write the CLI command to deploy the force-app directory to an org aliased 'my-scratch'.

Show hint

sf project deploy start --source-dir force-app --target-org my-scratch

BASH

Source-Driven Development with the CLI — Quick Check

1. Which command pulls metadata changes made in an org back down into local source?

2. In source-driven development, the org itself remains the permanent source of truth for metadata.

3. What should you do after making a quick change directly in a scratch org UI?

Log in to submit the quiz and save your score.

My Notes

Log in to keep private notes on this lesson.

Questions about this lesson

No questions yet — be the first to ask.

Log in to ask a question about this lesson.

Summary

sf project deploy start and sf project retrieve start move metadata between local source and any org, tracking exactly what changed and warning you about conflicts.