
If your team builds on Salesforce, you already know change moves fast: new fields, Flow updates, Apex fixes, and Lightning Web Components evolve weekly. Without a single source of truth, it’s easy for sandboxes to drift, releases to stall, and defects to slip into production. This is where source control—typically Git—becomes essential. In this guide, we’ll explain source control in clear terms and show how it pairs naturally with Provar so you can confidently Test Salesforce at every step.
We’ll keep the language straightforward, add simple visuals (lists and a compact table), and focus on practical steps you can adopt right away—no jargon required.
What Do We Mean by “Source Control” in Salesforce?
Source control is a system that tracks changes to your Salesforce configuration and code. Think of it as a versioned, shareable “blueprint” of your org. Instead of relying on what happens to be in a sandbox, you store your deployable components in a repository. That repository becomes your source of truth for how the org should be built.
Why It Matters
- Traceability: See who changed what, when, and why (every change is documented).
- Reproducibility: Rebuild environments reliably from the same blueprint.
- Teamwork: Multiple people can work in parallel without overwriting each other.
- Quality: Automate checks and run tests before changes reach users.
- Recovery: Roll back or forward to safe versions if something goes wrong.
What Should Go Into Git (and What Shouldn’t)?
A helpful way to think about this: if it must be deployed or recreated to make an org work, it belongs in source control. If it’s secret, volatile, or produced by an external vendor package, keep it out.
Item | Include? | Reason |
---|---|---|
Apex classes, triggers, and tests | Yes | It’s code. You’ll review, test, and deploy it. |
Lightning Web Components / Aura | Yes | Front-end behavior belongs with the same version history. |
Custom Objects, Fields, Page Layouts | Yes | Core metadata that defines data model and UI. |
Flows, Validation Rules, Record Types | Yes | These are powerful and risky; track them closely. |
Permission Sets (and Groups) | Yes | Preferred for access control; easier to manage than Profiles. |
Profiles | Sometimes | Keep minimal if possible; prefer Permission Sets to reduce conflicts. |
Managed package metadata | No | Treat as a dependency; don’t version vendor-provided XML. |
Secrets (tokens, keys, passwords) | Never | Use a secure secrets store in your CI platform. |
Seed/Test data recipes | Yes | Reproducible data makes tests reliable and fast. |
Popular Operating Models (Pick the Right Starting Point)
There’s no single “correct” approach. Choose the model that matches your team’s skill set and scale, then evolve as you grow.
1) DevOps Center (Admin-Friendly, Git-Backed)
- Best for: Teams just starting with Git or with strong admin presence.
- Benefits: Native UI for work items, versioning, and deployment orchestration.
- Trade-offs: Advanced patterns may still need CLI tooling and custom CI steps.
2) SFDX + Git (Flexible & Familiar)
- Best for: Cross-functional teams that want fine-grained control.
- Benefits: Works with any CI/CD tool, great for modular repos and automation.
- Trade-offs: Requires consistent conventions and lightweight scripting.
3) Unlocked Packages (Modular at Scale)
- Best for: Large orgs or product teams who want versioned modules.
- Benefits: Clean dependency graphs, easier upgrades, and isolation.
- Trade-offs: Requires upfront design and package governance.
Branching Made Simple
Keep your strategy easy to explain. Two patterns cover most needs.
Trunk-Based Development
- main is always stable and releasable.
- Short-lived feature/ branches that merge via pull requests.
- Use feature flags where you need partial, safe releases.
Lightweight “Gitflow”
- develop mirrors the integration sandbox; main mirrors production.
- Features merge into develop; cut release/x.y for stabilization.
- Tag production deployments for clear auditability.
Mapping Branches to Orgs (So Everyone Knows Where to Work)
- feature/* → Scratch orgs or dedicated Dev sandboxes (isolated work).
- develop → Integration sandbox (team testing, early end-to-end checks).
- release/x.y → UAT/Staging sandbox (final validation, training).
- main (tags) → Production (only from tested, approved tags).
CI/CD: What a Healthy Pipeline Looks Like
Your pipeline should prove every change is safe before users feel it.
- Checkout & static checks: Pull the repo, run Prettier/ESLint for LWC, and static analysis for Apex.
- Authenticate securely: Use JWT-based auth for sandboxes; no passwords in code.
- Validate deploy: Dry-run the metadata deploy to catch conflicts early.
- Run unit tests: Execute Apex tests with clear coverage expectations.
- Run end-to-end tests: Execute targeted Provar suites to verify real user flows.
- Publish results: Show pass/fail, coverage, and Provar outcomes on the pull request.
Data: Make Tests Predictable (and Fast)
Many “flaky tests” are actually “flaky data.” Stabilize your runs by making test data repeatable.
- Seed data scripts: Keep simple JSON/CSV loaders in the repo.
- Masking: Don’t use raw production data; anonymize sensitive fields.
- Factories: Use Apex factories for unit tests; use Provar data sets for end-to-end flows.
- Parameters: Store environment-specific values in CI/CD secrets, not in the repo.
Access Control: Prefer Permission Sets
Profiles are heavy and hard to merge. Permission Sets are modular and safer to version.
- Keep profiles minimal (e.g., login hours, default apps if required).
- Use Permission Sets and Permission Set Groups for role-based access.
- Verify access with both Apex checks and Provar persona-based test runs.
Reviews and Quality Gates (Human + Automated)
Reviewer Checklist
- Readable diffs (SFDX source format helps).
- No hard-coded IDs, secrets, or org-specific URLs.
- Flows versioned and named consistently; no leftover debug elements.
- Layouts remain usable; field-level security is respected.
Automated Gates
- Apex tests pass; coverage meets your policy (quality over “just coverage”).
- Provar smoke suite passes in the target sandbox (critical flows).
- Static checks clean (Apex, LWC).
- Validated deploy (dry-run) succeeds before merge.
Common Pitfalls (and Easy Fixes)
- Pitfall: Multiple people edit the same metadata in different sandboxes.
Fix: Use branches with clear ownership and short-lived feature work. - Pitfall: Giant Profile files causing merge pain.
Fix: Move access to Permission Sets; keep Profiles lean. - Pitfall: Flaky tests due to inconsistent data.
Fix: Commit seed scripts; rebuild data in CI as a standard step. - Pitfall: Deploying directly to production without validation.
Fix: Require validated deploys and PR approvals; tag releases. - Pitfall: Only relying on Apex tests.
Fix: Add Provar end-to-end checks to validate real user journeys.
How Provar Complements Source Control
Source control makes Salesforce changes predictable; Provar makes them provably correct in the ways users actually work. Because Provar is metadata-aware (rather than relying on brittle selectors), your tests stay resilient as the UI evolves.
- Version your tests: Store Provar assets alongside metadata so tests evolve with features.
- Automate in CI: Run Provar smoke tests on pull requests and broader suites on release branches.
- Traceability: Link work items and test outcomes through Provar Manager for complete visibility.
- Personas & environments: Parameterize connections and roles so the same suite runs reliably across dev, UAT, and prod-like sandboxes.
A Simple Four-Week Adoption Plan
- Week 1: Initialize an SFDX-formatted Git repo. Add a CI job that validates deploys to an integration sandbox.
- Week 2: Define branch names and pull-request rules. Add Apex and LWC linting.
- Week 3: Add a Provar smoke suite to CI. Commit seed data scripts.
- Week 4: Map branches to orgs. Pilot a
release/x.y
branch with automated UAT deploy and regression runs.
FAQs (Short & Practical)
Do we need to package everything?
No. Many teams ship effectively with SFDX + Git alone. Introduce Unlocked Packages gradually for stable domains (shared libraries, base data model).
What coverage should we target?
Salesforce requires 75% overall, but don’t chase percentage alone. Focus on meaningful tests—then verify end-to-end flows with Provar.
How do non-developers contribute?
DevOps Center is admin-friendly and Git-backed. Pair admins with a light PR review process and a clear naming convention.
Conclusion
Source control brings order, speed, and safety to Salesforce delivery. Whether you begin with DevOps Center or adopt SFDX with a simple branching model, the essentials are the same: store your deployable artifacts in Git, automate checks in CI, and prove user journeys before release.
Provar completes the picture. By pairing metadata-aware automation with version-controlled tests and pipeline integrations, Provar helps your team Test Salesforce continuously—so every change is deliberate, verifiable, and ready for production. If you’re ready to align your source control strategy with resilient Salesforce automation, the Provar team is here to help.