What is the difference between force:source vs force:mdapi?
The file and directory structures are different. force:source
refers to the new "source" format, while force:mdapi
refers to the old "metadata" format. As an example of the changes, in metadata format, a custom object is a single file, while in source format, an object has a core metadata file for the object itself, a folder full of files that represent each field, another folder for list views, etc.
... but when will I need to use force:source:deploy/retrieve?
For anything that is not a Scratch Org (including Production, Sandbox, and Developer Edition orgs). The difference here is that Scratch Orgs "track" changes, allowing developers to upload and download a delta (i.e. just the changes). Other orgs do not have this extra feature, and so you can only download and upload specified files, regardless if there has been any change. This means that it will typically take longer to upload and download changes, and it can be easier to miss changes.
What is the difference between force:mdapi:deploy/retrieve vs force:source: deploy/retrieve and when should they each be used?
If you have metadata formatted files, use force:mdapi
. If you have source formatted files, use force:source
. If you have neither, use the source format, as it is easier to work with.
The mdapi commands are to allow migration from existing source code repos to the newer format over time. You should prefer to use the force:source
commands whenever possible, and use the force:mdapi
commands only when dealing with legacy code repositories that have not yet been converted to "source" format.
Migrating to source format also means you'll get the advantage of 2GP (Second generation packages), which allows you to create versions, dependencies, etc, so you can just install packages instead of uploading metadata every time. This greatly reduces deployment times and grants additional features, like the ability to delete an obsolete field by removing it from a package.
You can get your goals done with nothing other than force:source (and optionally force:package) command(s). You can use a Developer Edition org, or you might even decide to eventually migrate to Scratch Orgs.