# Scratch Org Guidance

## Management of Scratch Orgs

The scratch org is a source-driven and disposable deployment of Salesforce code and metadata. They are great for temporary deployments, peer review, enhanced test coverage, and automation.

**You might spin up a new scratch org when you want to:**

* Start a new project
* Start a new feature branch
* Test a new feature
* Start automated testing
* Perform development tasks directly in an org
* Start from “scratch” with a fresh new org
* conduct user acceptance testing or to test installations of packages

#### Pushing Source to the Scratch Org

You can use `force:source:push` for scratch orgs only. If you’re synchronizing source to another org, use the Metadata API. The push command doesn’t 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.

**To push changed source to a scratch org that’s not the default, you can indicate it by its username or alias:** `sfdx force:source:push -u "Username"`

#### Selecting files for push to ignore:

It’s likely that you have some files that you don’t want to sync between the project and scratch org. You can have the push command ignore the files you indicate in .forceignore.

**Where to Put .forceignore**

* Be sure the paths that you specify in .forceignore are relative to the directory containing the .forceignore file. For the .forceignore file to work its magic, you must put it in the proper location, depending on which command you are running.
* Add the .forceignore file to the root of your project for the source tracking commands
  * `force:source:push`, `force:source:pull`, `force:source:status`, and `force:source:convert`
* Add the file to the Metadata retrieve directory (with package.xml)
  * `force:mdapi:convert`

Resources

* [Salesforce Source-Driven Development & Scratch Org](https://medium.com/@heruwala/salesforce-source-driven-development-and-scratch-org-2ccaccbcb191)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ecfmg.gitbook.io/sfdx-unlocked-packages-guide/supporting-infrastructure-and-environments/environment-types/scratch-org-guidance.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
