Version control records every change to a set of files, who made the change, and why, and lets teams branch, review, and merge work. For Salesforce, version control usually means keeping org metadata as files in a Git repository on a service such as GitHub, GitLab, Bitbucket, or Azure DevOps. The repository becomes a history of the org's configuration and code, and a shared place where admins and developers combine their work.
Why Version Control Matters for Salesforce
- History. Every change to code and configuration is recorded and can be compared or restored.
- Collaboration. Several people can work in parallel on branches and merge their work with review.
- Backup. The repository holds a copy of the metadata outside Salesforce.
- Automation. Repositories connect to automated tests and deployment pipelines.
Salesforce-Specific Challenges
- Changes made in Setup do not appear in the repository until someone retrieves them.
- File formats. Metadata can be stored in the Metadata API format or the Salesforce DX source format, and the formats are not interchangeable without conversion.
- Large files. Profiles and some other types produce large files where small changes are hard to review.
- The org is the runtime. The repository is only useful if what is in the repository matches what is deployed.
How to Approach Version Control
- Choose a format and keep the whole repository in that format.
- Retrieve the org into the repository to create the starting point.
- Capture Setup changes regularly so the repository does not fall behind the org.
- Deploy from the repository to sandboxes and production, so releases match what was reviewed.
- Compare the repository with each org to detect drift.
How Snapshot Helps
- Developer Project: holds metadata in a local folder or a Remote Repository in Metadata API File Format, Force.com IDE File Format, or Salesforce DX File Format. Download Assets replaces project files with selected org metadata, Clone Repository clones a repository (deleting existing project files), and Take Snapshot makes the project available for reporting and deployment between orgs and projects. Remote repositories require the Git command line.
- Metadata Differences Report: compares a project snapshot with an org snapshot to show drift.
- Deploy Metadata: deploys from a project to an org, or from an org into a project.
Project snapshots support metadata reports and deployment but not live data reports, and source status does not establish functional correctness.
Common Questions
Which format should a Salesforce repository use?
Salesforce DX source format splits large files into smaller ones, which suits Git and code review. The Metadata API format matches what the Metadata API retrieves. Pick one format for the whole repository.
How do changes made in Setup get into Git?
Someone must retrieve the changed metadata into the repository and commit the files. Regular captures keep the repository from falling behind.
Is a Git repository a backup of Salesforce?
A repository backs up metadata that has been retrieved into the repository. A repository does not back up Salesforce data.