# Useful Command reference

### Base

`sf org login web --alias MyOrg`

<p class="callout info">Login</p>

`git add . && git commit -m "My Commit Message" && git push`

<p class="callout info">quick and dirty commit everything from local</p>

`git remote update origin --prune`

<p class="callout info">get all Branches from remote and remove the deleted ones from your local</p>

### Deployments

`sf project retrieve start --target-org MyOrg --ignore-conflicts --wait 20  `

Retrieve changes from Org. Assumes Source Tracking is on.

`sf project retrieve start --target-org MyOrg --ignore-conflicts --wait 20  -x manifest/package.xml`

<p class="callout info">Get the metadata listed in the package from the Org</p>

`sf project retrieve start --target-org MyOrg --ignore-conflicts --wait 20  -m InstalledPackage:FSL`

<p class="callout info">Retrieve specific metadata from the org. Based on the Metadata Types from SF https://developer.salesforce.com/docs/atlas.en-us.api\_meta.meta/api\_meta/meta\_types\_list.htm</p>

`sf project deploy start --target-org MyOrg --ignore-conflicts --wait 20`

<p class="callout info">Deploy the source. Does destructive changes and assumes source tracking</p>

`sf project deploy start --target-org MyOrg --source-dir force-app --ignore-conflicts --wait 20`

<p class="callout info">Deploy the metadata contained in the force-app folder. Does not do destructive changes.</p>

`sf project deploy start --target-org MyOrg --manifest package/package.xml --pre-destructive-changes destructiveChanges/destructiveChanges.xml --ignore-conflicts --ignore-warnings --wait 20 --dry-run`

<p class="callout info">Same as previous but validates only</p>

### Using SGD

`sf sgd:source:delta --to HEAD --from HEAD~1 --output-dir . -i .sgdignore`

<p class="callout info">sgd - do delta from last commit to current commit, generate the package.xml and destructivechanges in the current directory, and ignore directories listed in .sgdignore</p>

`sf project deploy start --target-org MyOrg --manifest package/package.xml --pre-destructive-changes destructiveChanges/destructiveChanges.xml --ignore-conflicts --ignore-warnings --wait 20 --dry-run`

<p class="callout info">sgd - do a Salesforce Project deploy based on the generated manifest from SGD, and do destructive changes before running anything else based on the destructivechanges.xml</p>