A Guide to Git and Version Control for Salesforce Admins

A Guide to Git and Version Control for Salesforce Admins

Navigating Version Control: A Comprehensive Guide for Salesforce Admins

Version control lies at the core of the contemporary DevOps process for Salesforce, offering numerous advantages to teams comprising administrators and developers. With the integration of version control into their development and release procedures, these teams experience enhanced collaboration and various other benefits. This article provides a comprehensive overview of Git-based version control, elucidates the significance of version control in a streamlined Salesforce release process, and highlights the resultant advantages.

Furthermore, an additional article titled "Implementing Source-Driven Workflows: Best Practices for Salesforce Developers" offers guidance for Salesforce teams seeking to adopt optimal approaches to version control.

What sets DevOps for Salesforce apart from other methodologies?

To begin, let's define DevOps within the context of Salesforce. DevOps, the convergence of development and operations, is a relatively recent concept in the Salesforce ecosystem. This is primarily due to the fact that Salesforce simplifies many of the complexities found in other platforms by managing hosting, scalability, and infrastructure, which are typically the responsibilities of an operations team.

Salesforce administrators, in particular, have greatly benefited from the platform's unique approach of "clicks not code" for org configuration. This approach empowers administrators to make changes without the need for complex developer tools. By democratizing development and customization capabilities, Salesforce enables companies to realize a quicker return on investment. However, as a consequence, the adoption of industry-standard tools and processes commonly used outside the Salesforce ecosystem has not always been rapid.

The traditional release management process followed by most teams in the early days, which involved pushing changes through a series of Salesforce orgs, no longer works effectively. Teams encounter issues such as overwriting each other's work and spending excessive time on deployments without any means of expediting the process. DevOps addresses these problems, with version control serving as the foundational element that allows you to incorporate the following into your workflow:

  1. Review and testing

  2. Rollback options

  3. Repeatability

  4. Automation

  5. Team ownership

Instead of relying on a dedicated DevOps team, teams comprising Salesforce administrators and developers assume responsibility for the entire development and release cycle. Moreover, for those concerned about the complexity of learning intricate developer tools, Salesforce DevOps can be achieved without writing code, utilizing a "clicks not code" approach.

Version control has become a critical necessity for teams working with Salesforce.

Version control is not a novel concept; it has long been a fundamental tool for release management in various platforms. However, Salesforce teams were relatively slower in embracing version control due to the aforementioned reasons. Nonetheless, in recent years, there has been a significant shift in this trend.

As the Salesforce platform has evolved and introduced more sophisticated functionalities, it has become evident that version control is an indispensable tool for every Salesforce team. The ecosystem has witnessed a substantial transition towards source-driven workflows. In fact, Gearset's State of Salesforce DevOps 2021 report, which surveyed over 500 Salesforce professionals, revealed that nearly 70% of them have already incorporated version control into their processes to some extent.

What does version control entail?

Before delving into the significance of version control in Salesforce DevOps, let's provide a brief overview of what version control entails.

Version control is a mechanism that tracks changes made to files over time, encompassing various types of files ranging from text files to the Salesforce metadata that forms the structure of your organization. It offers a comprehensive history of every modification made to any file, regardless of the time or the person responsible.

Multiple versions of version control exist, with Git being the standard choice for Salesforce. Git enables teams to separate multiple development streams and prevent conflicts by making changes in isolated branches rather than shared sandboxes. It replaces the production org as the shared source of truth for the entire team. Each repository possesses a "main" or "master" branch containing the latest "production ready" versions of all files. By having everyone work from this central starting point, teams can easily maintain a shared understanding of reviewed changes.

Version control facilitates the review and integration of changes before their release, allowing conflicts to be resolved in advance. The combined features of version control provide significant advantages over Salesforce's native change management process. They enhance collaboration with developers, enabling smoother coordination and comprehensive management of changes as they progress toward production.

How do teams engage with version control in their workflow?

The most effective approach to familiarize oneself with the terminology surrounding version control is by visualizing its concepts.

In version control, all project files, including Salesforce metadata like profiles, custom objects, and custom Apex code created by the team's developers, are stored within a repository or "repo." This repository keeps track of the change history associated with these files.

Typically, Salesforce teams have a centrally hosted repo that serves as the primary source of truth. This repo is often hosted on a Git hosting platform such as GitHub or GitLab. Both administrators and developers can interact with the centrally hosted repo using a clicks-based DevOps solution specifically designed for Salesforce. While developers also work with a local copy of the repository on their own computers, third-party DevOps tools enable administrators to manage deployments between the version control system and various Salesforce orgs.

Setting up a deployment to version control using clicks not code

Branching: When initiating modifications to a sandbox or introducing a new feature in a development environment, the process begins by creating a distinct branch, often referred to as a "feature" branch, derived from the "main" or "master" branch. This feature branch contains a replica of all the files present in the main/master branch. By creating this separate branch, individuals can confidently make alterations to files in an isolated environment without affecting their teammates' work. This can be accomplished without requiring a developer's command-line interface (CLI) if the team employs a third-party tool that supports branch creation and deployment.

Committing changes: While working on changes within the org, it is advisable to periodically "commit" (deploy) those modifications to the feature branch. It is good practice to perform commits at various stages, after each logical step in the work. Each branch represents a collection of interconnected changes that ultimately contribute to the final feature being developed. Salesforce DevOps tools with user interfaces can be utilized to facilitate deployments from a sandbox to the version control system.

Pull requests: Upon completing the work, a "pull request" is generated to merge the feature branch back into the main branch. A pull request serves as a means for review, approval, and automating the process of merging files before the changes are released into downstream orgs and, eventually, into production.

A unified and collaborative workflow for both administrators and developers.

Now, let's consolidate all the information into a fundamental source-driven workflow for Salesforce, which can be summarized as follows:

In the provided illustration, an administrator operates within a sandbox, deploying changes as commits to a feature branch, and subsequently initiating a pull request to merge the work into the master branch. Similarly, the developer follows a similar process, with the distinction that new features are initially developed in an integrated development environment (IDE) before being deployed to a sandbox or Salesforce development environment. These changes can be collectively released, including production.

The crucial aspect is that every team member utilizes a unified source of truth in version control and employs the same process for deploying changes throughout the pipeline. This collaborative approach unlocks significant advantages and benefits for the team.

The advantages of utilizing version control in the workflow.

Teams that utilize version control experience a range of significant benefits, including the following:

  1. Improved scalability of collaboration: Version control allows multiple administrators and developers to work on the same org simultaneously, mitigating the risks of overwritten changes, conflicts, and production issues. Through branching in version control, teams can effectively work in parallel on the same features and scale their release process to accommodate teams of any size.

  2. Automated deployments and testing: Once a well-established manual process is established with a Git-based workflow, teams can introduce automation. Automation facilitates the synchronization of environments, testing and validation of changes, and eliminates the challenges and risks associated with manual deployments across multiple sandboxes, testing environments, and production orgs. Automation is a crucial element of DevOps, providing a repeatable and expedited approach to deploying changes between Salesforce orgs.

  3. Increased release velocity: Streamlined deployments enable more frequent releases, encouraging teams to ship smaller batches of changes at a time. This approach simplifies testing processes and reduces the risk associated with each release. In the event of issues, it becomes easier to revert or rollback a smaller number of changes rather than an extensive configuration spanning a longer timeframe.

  4. Higher-quality, lower-risk releases: The rapid cadence facilitated by version control promotes iterative development cycles and regular feedback, leading to higher-quality releases with features that are more relevant to end users. This iterative approach and tighter feedback loops result in substantial improvements within the deployment pipeline compared to traditional change sets.

In summary, version control empowers teams to achieve enhanced collaboration, leverage automation for deployments and testing, accelerate release velocity, and ensure higher-quality, lower-risk releases.

Looking to grasp the concept of version control?

Regardless of whether you work as an administrator, developer, or architect, possessing DevOps expertise in the Salesforce ecosystem is highly sought after. Thus, there is no better time than now to begin acquiring these valuable skills.