Salesforce developers have long faced challenges with version control and collaboration due to the platform's unique nature. This makes it problematic to integrate with standard version control systems like Git. However, there is good news for Salesforce enthusiasts.
It is no secret that Salesforce lacks built-in version control for metadata. Git has become a defacto standard for developers worldwide across most software development technologies due to its:
This makes it an ideal candidate for managing source code and metadata of any kind, including Salesforce metadata.
Using “shadow version control” – occasionally pulling all metadata of an org and storing it in Git for backup purposes – has been a common practice for many Salesforce teams for a long time.
Together, these tools bridge the gap between Salesforce and Git, simplifying the management and collaboration on Salesforce projects.
Understanding the benefits of using Git with Salesforce development (and the steps to implement it) is crucial.
Effective version control is essential to unlocking the full benefits of a robust DevOps process for Salesforce. It paves the way for automation, streamlining development and release cycles. This enables Salesforce teams to build, test, and deploy code and configurations more efficiently.
However, teams must overcome common challenges to implement source-driven and automated workflows successfully.
Version control's adaptability, which is its strength, can also cause complications that make it challenging to adopt.
When teams begin using version control, they encounter multiple obstacles. Primarily, two initial hurdles must be overcome:
Now that you know about the challenges behind version control, let’s look at how Git-based development comes in and saves the day.
As mentioned previously, Git-based development means no longer considering a Salesforce org the “source of truth” of your configuration, but rather your version control system.
Git-based development allows developers to:
This approach has become a widely accepted best practice for software development because it can improve team engagement, increase efficiency, and refine the development process.
Git-based development is used in various software development environments, including web development, mobile app development, and enterprise software development.
Salesforce has introduced the DevOps Center, which promotes Git-based development on the Salesforce platform for both low-code and pro-code development. However, as the tool is still rather new, it has left many vital gaps for the ecosystem of Salesforce DevOps solutions to close.
Utilizing Git-based development offers several benefits, such as:
With Git, release management becomes more efficient as developers can easily control code alterations and explore new features in the main codebase.
Git-based development is widely used and has extensive documentation, making it easy for developers to learn and get started. There are various resources and courses available to help you grasp Git faster. A good place to start would be on Trailhead. You can learn at your own pace while gaining invaluable knowledge and insights.
By providing a collaborative and efficient development process, Git-based development can help developers become more productive, resulting in faster development cycles and better-quality code.
This type of development allows teams to create and manage multiple code branches, enabling them to work on different features or fixes simultaneously and easily merge the changes into the main codebase.
Git enables developers to create self-operating deployment workflows, reducing the risk of deployment errors and improving the overall deployment process.
Git-based development allows developers to work on different development environments, including local, staging, and production environments, without interfering with each other's work.
It also gives managers options for different types of code. Git can be used for various development projects, from small-scale projects to large-scale enterprise applications.
Git has a strong community of developers who contribute to its development and provide support to others.
Git-based development provides better tracking of bugs and issues by enabling developers to associate specific functions with specific bugs or problems and providing an audit trail of changes made to address those issues.
Git integrates easily with other development tools, such as continuous integration and deployment tools, making it easier to self-act the development process.
To protect sensitive code and data, Git-based development offers robust security features, such as user authentication, access control, and encryption.
Git offers an efficient way to document code changes, enabling developers to create clear and concise documentation of their code, This makes it easier to understand and maintain the codebase.
For those interested in implementing Git-based Salesforce development, there are straightforward steps that can be followed.
Install a set of free tools. These tools can be Salesforce DX, Visual Studio Code with the Salesforce extension pack, and Git.
To get started, use Salesforce DX to establish a connection between your computer and your existing Salesforce org. This can be achieved by accessing the Command Palette, choosing "Command Salesforce DX," and selecting "Authorize an Org."
In the past, retrieving metadata from your org was a difficult task, but with Salesforce DX, this functionality is now built-in.
The first command generates a "package.xml" file that includes a list of metadata from your org. The second command then uses this file to fetch the specified metadata.
sfdx force source manifest create -t package --fromorg <orgalias> sfdx force source retrieve -x package.xml -u <orgalias>
To get started, visit a Git host such as:
Firstly, establish a secluded repository and acquire its URL upon completion.
In case your organization's security policies prohibit the use of cloud-based repository hosting, alternative options provide enterprise-grade security features.
git init git add . git commit -m "initial metadata fetched from org" git remote add origin <url of your repo> git push -u origin main
There are three categories of organizations that endorse source tracking:
Although both sandboxes and scratch orgs are viable alternatives, some see scratch org-based development as the preferred method.
Typically, scratch orgs are ideal if your project allows for reverting to sandboxes.
Developers who contribute to your source code will require specific instructions to fetch their work from their source-tracked organizations and submit changes made in their local environment, usually using code from Apex or Lightning Web Components.
sfdx force source push sfdx force source pull
Once a unit of work is finished, you can use the built-in capabilities, Visual Studio Code, or command line to commit and push it to Git.
While they provide a fundamental understanding, Git involves additional complexities, including branching strategies and other commands, that are worth exploring.
For some members of the Salesforce team, such as admins and low-code or no-code developers, this could be overwhelming. It is the primary obstacle encountered by Salesforce teams when transitioning to a Git-based application lifecycle.
Fortunately, third-party tools like Hutte can simplify the process of shifting to Git, enabling both coders and non-coders to collaborate in a development workflow within Salesforce.
To finalize the workflow, it is necessary to generate a pull request, which can be achieved through the GitHub user interface or command line. Pull requests are a crucial step in Git-based development, allowing you to refine your work before submission.
Most Git hosting services generate a unique URL when you push your branch, which can be utilized to create a pull request through a web browser. Alternatively, you can use the command line to submit your pull request.
Here is an illustration of code to generate a pull request using GitHub CLI:
gh pr create --title "my title"
Depending on how your team is structured, some contributors may choose to finalize their Git development by submitting a pull request.
Once a pull request has been submitted, it is typically reviewed and merged by the release manager, followed by promotion to higher environments, such as user acceptance testing or production. This can be accomplished either manually or with the assistance of automation.
Despite being an efficient approach to promoting changes, 2GP is often overlooked, and there are Salesforce DX plugins available to facilitate this process.
Here is a sample of how to deploy the metadata from the most recent merged pull request in Git to a Salesforce sandbox or production org:
sfdx sgd source delta --from "HEAD~1" --to "HEAD" --output "." --ignore .forceignore sfdx force source deploy --manifest package/package.xml --postdestructivechanges destructiveChanges/destructiveChanges.xml --wait 30 --testlevel RunLocalTests
Development based on Git enables the implementation of various automation alternatives, such as carrying out code checks and performing frontend or unit tests.
The options are vast. Nevertheless, it is wise to commence with basic automation capabilities and progressively enhance them.
Hutte has made Git-based development accessible to everyone, including non-technical members of product teams.
It simplifies the creation and management of scratch orgs and sandboxes, enabling developers to spend more time coding and less time manually creating developer orgs via the CLI.
Hutte offers an easy-to-use interface on the frontend while providing a powerful backend to help development teams take advantage of the benefits of Git-based development.
There, teams can perform no-code work and create a pull request – all in a no-code way. Meaning, even if you (or your team) don't know code, you can still generate development projects.
Users and teams don't need to learn how to install and use command-line tooling and Git.
Creating scratch orgs usually takes up hours of developers' time every week. That’s why Hutte is a huge time-saver, as you can take a fully prepared development environment from the pool within a few seconds. This enables Hutte to boost the productivity of teams daily.
The world of Git-based Salesforce development is where code collaboration and version control go hand in hand.
Git-based Salesforce development aims to bridge the gap between the powerful Salesforce platform and the robust version control system, Git.
This partnership enables you to:
This makes it the ultimate alliance.
Instead, you'll be working with development with Git-powered version control backing you up. But it can be pretty daunting to adopt Git if you don’t have the right third-party tool to help you.
As previously stated, Hutte facilitates both code and no-code development, eliminating the complexity of a command-line interface and Git. With Hutte, you can maintain complete transparency and flexibility, making it an ideal solution for Salesforce development teams.
So, why not give Git-based Salesforce development a chance and start enjoying the benefits of this perfect match in coding utopia.