Sub topic 2
Source control as the source of truth
This chapter assumes you know Salesforce sandboxes and metadata, and basic Git: branches, commits, pull requests and merges. It explains why DevOps Center treats a Git repository as the authoritative record of your release, and what that changes in daily work.
Why the repository, not the org
With change sets, each org is its own record of truth. A change set is a one-time package of components, and nothing records who changed what or why. Two sandboxes can drift apart without anyone noticing.
In source-driven development, the Git repository holds the approved version of your metadata. Orgs are places where that version is tested and run. If an org and the repository disagree, the repository wins. You can rebuild any environment from it, and every change has an author, a timestamp and a review trail.
What the repository contains
Metadata is stored as files in an sfdx-project.json project layout. The project file names the directories Git tracks.
{
"packageDirectories": [
{ "path": "force-app", "default": true }
],
"namespace": "",
"sfdcLoginUrl": "https://login.salesforce.com",
"sourceApiVersion": "62.0"
}Everything under force-app is tracked. Anything else in the repository, such as editor settings or test caches, should stay out of deployments. A .forceignore file does this.
# .forceignore
**/jsconfig.json
**/.eslintrc.json
**/__tests__/**
.sfdx
.sfBranches map to pipeline stages
DevOps Center ties each pipeline stage to a branch. A change moves forward when its work item branch is merged into the next stage's branch.
You can check what a promotion would carry by comparing two stage branches in Git. This lists commits that reached UAT but not yet main.
git fetch origin
git log --oneline origin/main..origin/UATWhat this changes in practice
| Change set approach | Source-driven approach |
|---|---|
| Org holds the truth | Repository holds the truth |
| Components picked by hand | Changes recorded as commits |
| No built-in history | Full history and authorship |
| Review is informal | Review through pull requests |
Common errors
- Committing local tooling files because
.forceignoreis missing or incomplete. - Treating a sandbox as the source of truth and copying changes by hand.
- Using a
sourceApiVersionthat differs from what your orgs support, which causes deployment failures.
Exercise
A teammate fixes a bug directly in the UAT sandbox and does not commit it. Why is this a problem when the repository is the source of truth?
Show answer
The fix exists only in that org. The UAT branch does not contain it, so the next promotion or org refresh can overwrite or lose the fix, and the org and repository are now out of sync.