Often only associated with developers, version control and Git are becoming more relevant to Salesforce administrators. The concept can be intimidating for those with little technical experience, solo admins, or even admins who are part of a team regardless of size.
Version control can serve Salesforce admins well in managing and stewarding their org as it has many advantages over other workflows.
Ultimately, a deep understanding of version control gives you a deeper understanding of Salesforce and the changes you’re making, making you a better, more thoughtful admin.
What is Version Control and Git?
Essentially, version control in Salesforce is a way to track changes in files. These files contain the metadata that forms the org’s framework–incuding configurations such as flows, objects, apex triggers, classes, and tests.
You can implement version control in many ways, but Git is the standard choice for Salesforce. Git allows different people to work in isolated environments without the risk of overwriting someone else’s work.
With Git, the files are kept in a repository. The main branch of that repository holds all the files that (should!) correlate to the production org.
Gearset, Copado, and many other tools all have a UI dedicated to manage version control and the development pipeline, but may be cost prohibitive depending on the team and budget.
We’ve found VS Code with GitHub (or another repository host) to be more cost effective for smaller teams.
Branching
Besides the main branch, various other branches represent work in progress. These branches also have copies of the files but allow work to be performed independently of other work. The files on these branches correlate to whatever work is happening.
If two admins are working on features that involve the same objects, branches in Git can represent that work without the files for one feature possibly overwriting the other.
Depending on a specific workflow, branches can represent a dev, staging, or QA environment, development of a specific feature, or any other work being performed.
Committing Changes
As you make modifications, you commit those changes to your branch, effectively saving the changes within the metadata files.
You should commit often as you work instead of all at once when you’re finished, and each commit should correspond to a logical piece of work (for example, all the changes to a page layout or changes for each flow if you’re working on multiple flows).
Pushing to Production
Once all the changes are on the branch, you will open a pull request to merge the changes into the main branch, or whatever branch is next in your pipeline.
Pull requests are typically reviewed by other people to ensure accuracy, quality, and that the customizations achieve the outcome.
Why Version Control?
Deep Dive
- Even a small change can have a ripple effect throughout an org. Thinking of your org in terms of metadata files helps you realize how a change can affect other parts of the org.
- This makes you more aware of how Salesforce is built, the effect of technical debt on your org, and the extent of configuration involved in even the smallest change.
Tracking Changes
- Using version control means you have a history of the metadata files in your org. You can see when they were changed, who changed them, and the content of the files before the change.
- Not only do you have a history of the changes in production, but you can keep a history of changes in development or waiting to be deployed to production.
- You know, down to the line number, the modifications made to your metadata.
Rollback, Recovery, and Security
- If something goes wrong, you can easily restore a previous version of your org from the files in the repo. On a larger scale, you have a backup of your org’s configuration.
- If you work in an industry where security and compliance are especially important, you have an audit trail.
Collaboration
- Version control makes it easier to work with other admins, developers, and consultants. It’s clear what person made what changes when.
- However, this requires everyone’s buy in. If everyone involved in the project doesn’t understand the importance of version control and use it, your history will be incomplete, which undermines the very reason for using it to begin with.
Getting Started with Git
Many tools make managing org metadata easier, but understanding what is going on ‘under the hood’ reinforces the development pipeline and furthers the admin’s understanding of the metadata that lies underneath their org.
Resources