Newer Version Available
Pull Source from the Scratch Org to Your Project
During development, you change files locally in your file system and change the scratch org using the builders and editors that Salesforce supplies. Usually, these changes don’t cause a conflict and involve unique files.
By default, only changed source is synced back to your project.
The pull command does not handle merges. Projects and scratch orgs are meant to be used by one developer. Therefore, we don’t anticipate file conflicts or the need to merge. However, if the pull command detects a conflict, it terminates the operation and displays the conflict information to the terminal. You can rerun the command with the force option if you want to pull changes from your scratch org to the project despite any detected conflicts.
Before you run the pull command, you can get a list of what’s new, changed, and any conflicts between your local file system and the scratch org by using force:source:status. This way you can choose ahead of time which files to keep.
To pull changed source from the scratch org to the project:
1sfdx force:source:pullYou can indicate either the full scratch org username or an alias. The terminal displays the results of the pull command. This example adds two Apex classes to the scratch org. The classes are then pulled to the project in the default package directory. The pull also indicates which files have changed since the last push and if a conflict exists between a version in your local project and the scratch org.
1STATE FULL NAME TYPE PROJECT PATH
2─────── ───────────── ───────── ─────────────────────────────────
3Changed MyWidgetClass ApexClass /classes/MyWidgetClass.cls-meta.xml
4Changed MyWidgetClass ApexClass /classes/MyWidgetClass.cls
5Changed CoolClass ApexClass /classes/CoolClass.cls-meta.xml
6Changed CoolClass ApexClass /classes/CoolClass.clsTo pull source to the project if a conflict has been detected:
1sfdx force:source:pull --forceoverwrite