1

I've added a couple of Apex classes locally but also changed a Profile in the scratch org.

When I run:

sfdx force:source:status

I get a response with Local Add and Remote Changed and Remote Add

STATE           FULL NAME              TYPE       PROJECT PATH
──────────────  ─────────────────────  ─────────  ──────────────────────────────────────────────────────────────────
Local Add       AppInstallHandler      ApexClass  app\main\default\classes\AppInstallHandler.cls
Local Add       AppInstallHandler      ApexClass  app\main\default\classes\AppInstallHandler.cls-meta.xml
Local Add       AppInstallHandlerTest  ApexClass  app\main\default\classes\AppInstallHandlerTest.cls
Local Add       AppInstallHandlerTest  ApexClass  app\main\default\classes\AppInstallHandlerTest.cls-meta.xml
Remote Changed  Admin                  Profile    app\main\default\profiles\Admin.profile-meta.xml
Remote Add      MyConnectedApp         ConnectedApp

I want all the additions\changes.

Last time I had this situation, I did:

sfdx force:source:pull

And then the Local Add disappeared from my source:status report, but files still existed locally, but they were not in the remote scratch org!

What sequence of SFDX commands should I run to ensure, that all the changes are synced, so they exist in both the org and locally?

1 Answer 1

2

The order is as follows

  1. If you do any config in the org, use sfdx force:source:pull

  2. If you add a local file or change a file locally do sfdx force:source:push

  3. If there is a conflict resolve it and do a force push using -f flag using sfdx force:source:push -f to overwrite the org and overwrite the local files use sfdx force:source:pull -f

In case you do not want a file to be source tracked use .forceignore file

Update

Use git or any other version control tool and keep synching your source often! That way you don't loose anything at all.

8
  • Thanks Mohith, but I am aware what pull and push do independently, I am more concerned about what I should do when I have changes both remotely and locally. Because earlier today when I had this exact same situation, I did pull and then source:status lost track of my local changes, so I could no longer do push
    – Robs
    Nov 1, 2020 at 15:13
  • The pull should not have overridden local changes if there are changes you did locally and instead should have shown conflicts, should not have affected local added files. If you reproduce file a bug with repro steps. Nov 1, 2020 at 15:16
  • In the end, I did a push and then pull and it worked fine...
    – Robs
    Nov 1, 2020 at 15:26
  • 1
    I also recommend use a version control that way you can easily version and you won't loose anything in case something goes wrong Nov 1, 2020 at 15:31
  • 1
    That is next on my list... :-)
    – Robs
    Nov 1, 2020 at 15:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .