3
  1. Run following command:

    sfdx force:source:push

Following error has been received:

ERROR: We couldn't complete the push operation due to conflicts. Verify th at you want to keep the local versions, then run "sfdx force:source:push -f " with the --forceoverwrite (-f) option. STATE FULL NAME TYPE PROJECT PATH ──────── ───────────────────────── ───────── ─────────────────────────── ─────────────────────────────────────── Conflict TransactionSyncEvent ApexClass forceApp/main/core/src/even t/classes/TransactionSyncEvent.cls ERROR running force:source:push: Source conflict(s) detected.

  1. sfdx force:source:push --json command returns following log:
{
"status": 1,
"result": [
{
"state": "Conflict",
"fullName": "TransactionSyncEvent",
"type": "ApexClass",
"filePath": "forceApp/main/core/src/event/classes/TransactionSyncEvent.cls"
}
],
"name": "sourceConflictDetected",
"message": "Source conflict(s) detected.",
"exitCode": 1,
"commandName": "SourcePushCommand",
"data": [
{
"state": "Conflict",
"fullName": "TransactionSyncEvent",
"type": "ApexClass",
Dmitriys-MacBook-Pro:myapp dmitriyprozorovskiy$ sfdx force:
source:push --json
{
"status": 1,
"result": [
{
"state": "Conflict",
"fullName": "TransactionSyncEvent",
"type": "ApexClass",
"filePath": "forceApp/main/core/src/event/classes/Transact
ionSyncEvent.cls"
}
],
"name": "sourceConflictDetected",
"message": "Source conflict(s) detected.",
"exitCode": 1,
"commandName": "SourcePushCommand",
"data": [
{
"state": "Conflict",
"fullName": "TransactionSyncEvent",
"type": "ApexClass",
"filePath": "forceApp/main/core/src/event/classes/Transact
ionSyncEvent.cls"
}
],
"stack": "sourceConflictDetected: Source conflict(s) detected.\n at
ALMError (/Users/dmitriyprozorovskiy/.local/share/sfdx/node_modules/salesfo
rce-alm/dist/lib/core/almError.js:44:19)\n at MetadataRegistry.initializ
eMetadataTypeInfos.then.then.catch.e (/Users/dmitriyprozorovskiy/.local/sha
re/sfdx/node_modules/salesforce-alm/dist/lib/source/sourceApiCommand.js:54:
31)\n at tryCatcher (/Users/dmitriyprozorovskiy/.local/share/sfdx/node_m
odules/bluebird/js/release/util.js:16:23)\n at Promise._settlePromiseFro
mHandler (/Users/dmitriyprozorovskiy/.local/share/sfdx/node_modules/bluebir
d/js/release/promise.js:517:31)\n at Promise._settlePromise (/Users/dmit
riyprozorovskiy/.local/share/sfdx/node_modules/bluebird/js/release/promise.
js:574:18)\n at Promise._settlePromise0 (/Users/dmitriyprozorovskiy/.local/share/sfdx/node_modules/bluebird/js/release/promise.js:619:10)\n at Promise._settlePromises (/Users/dmitriyprozorovskiy/.local/share/sfdx/node_modules/bluebird/js/release/promise.js:695:18)\n at _drainQueueStep (/Users/dmitriyprozorovskiy/.local/share/sfdx/node_modules/bluebird/js/release/async.js:138:12)\n at _drainQueue (/Users/dmitriyprozorovskiy/.local/share/sfdx/node_modules/bluebird/js/release/async.js:131:9)\n at Async._drainQueues (/Users/dmitriyprozorovskiy/.local/share/sfdx/node_modules/bluebird/js/release/async.js:147:5)\n at Immediate.Async.drainQueues [as _onImmediate] (/Users/dmitriyprozorovskiy/.local/share/sfdx/node_modules/bluebird/js/release/async.js:17:14)\n at runCallback (timers.js:705:18)\n at tryOnImmediate (timers.js:676:5)\n at processImmediate (timers.js:658:5)\nOuter stack:\n at Function.wrap (/Users/dmitriyprozorovskiy/.local/share/sfdx/node_modules/@salesforce/core/lib/sfdxError.js:151:27)\n at SourcePushCommand.catch (/Users/dmitriyprozorovskiy/.local/share/sfdx/node_modules/salesforce-alm/dist/ToolbeltCommand.js:247:46)",
"warnings": []
}

Expected result
sfdx force:source:push executes successfully

VS Code Version:
Version: 1.41.1

SFDX CLI Version:
sfdx-cli/7.44.0-e77f9c8515 darwin-x64 node-v10.15.3 - latest version

OS and version:
OS: Darwin x64 18.7.0

enter image description here

  • 2
    It's a standard behavior , if your local version is different than the Salesforce server version then this will happen. Why dont you compare the conflicted class and then just force:source:push -f to force overwrite it . – Mohith Shrivastava Feb 1 at 16:16
  • Not sure that it's standard behavior, before I pushed my code and it worked good. I tried to use -f flag, it worked, but then I added just a space ' ' to the class, saved it, tried to push it and received this error again. It happens not only with this class, but with others classes too if I try to update these files – Dmitry Prozorovskiy Feb 1 at 16:19
  • Try doing an sfdx force:source:pull once and see if it improves. – Mohith Shrivastava Feb 1 at 17:36
  • 1
    Created new scratch org. First push executed successfully. Then added space and pushed again. Received an error. Then executed pull -f (without -f doesn't work). Then again added space to the class. Pushed successfully. Then removed space, tried to push one more time, received error. Seems that it helps only for the first push after I pulled changes. – Dmitry Prozorovskiy Feb 1 at 20:18
  • Does SFDX CLI user (I.e. you) have permissions to write to the local file system, most specifically the .sfdx folder structure at the root of your project? Details for conflict detection and incremental deployment get stored in a scratch-specific folder within this directory. – Phil W Feb 2 at 7:43
1

This appears to be a bug. Running sfdx force:source:status -a (or "SFDX: View All Changes" in the VS Code plugin) shows you remote and local changes, but in this case reports remote changes even when the files are identical. You can verify this using the Source Diff plugin (currently in beta).

The quick and easy workaround is to use the -f "force" option in your push command (sfdx force:source:push -f, or look for "...Override Conflicts" in the VS Code command palette). But be aware you should also exercise caution when collaborating with other developers, so as not to override someone else's work.

Unfortunately this also makes the "push on save" feature redundant, but there is a workaround for that too. Using Multi-Command for VS Code you can configure a single keybinding to save and auto-push with the --force option.

1 - Install the Multi-Command for VS Code plugin using VS Code.

2 - Add the following to your settings.json

"multiCommand.commands": [
    {
        "command": "multiCommand.saveAndForcePush",
        "sequence": [
            "workbench.action.files.save",
            "sfdx.force.source.push.force"
        ]
    }
]

3 - Add the keybinding to your keybindings.json file (it's in the same directory as settings.json)

{
    "key": "Ctrl+Shift+s",
    "command": "multiCommand.saveAndForcePush",
    "when": "editorTextFocus"
}

This sets Ctrl+Shift+s as a hotkey to first save the file locally, then use SFDX force push. Change the hotkey as required (VS Code Keybinding docs for more details).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.