Resolving Merge Conflicts in Salesforce

Aug 21, 2017

Code clobbering is a pain. But as Salesforce sandbox strategies get increasingly complex it can be difficult to avoid. Many teams have multiple people working on multiple features in multiple sandboxes. Some resort to spreadsheets to manage the chaos. But still, even with spreadsheets, it can be all too easy to push a change set that overwrites the code of a colleague or causes you to lose some important metadata. One team we work with lost nearly 6-months of developer time due to an inadvertent push to a sandbox. They had no source control and no backup of their Salesforce code. This can costs tens of thousands of dollars.

Git is wonderful because it solves code clobbering. First of all it gives you a backup of every change and the ability to revert to previous snapshots of your code base. So whenever you push a change, all is not lost. Instead you have a continuous history of who is changing what and when.

But Git is also designed to specifically handle merge conflicts. Because Git keeps a comprehensive history, it can detect when changes happen in one branch that conflict with changes in another. When you go to merge these branches, instead of just overwriting one with the other, Git raises its hand and asks “Are you sure?” Even more useful, Git will show you the exact lines of code that are different and let you “resolve” the conflict by selecting which you want to use.

One of the best things about using Git for Salesforce is that you can handle merge conflicts seamlessly and combat the tendency for work done on one sandbox to overwrite the work done on another (Note: You can even sometimes overwrite yourself! We have heard stories of one person teams overwriting work that they made on a previous sandbox accidentally).

Because Blue Canvas is a simple, automatic, easy to use Git implementation for Salesforce, it makes handling merge conflicts very simple.

Automatically Sync all Salesforce Changes to Git

With Blue Canvas, every change is automatically committed into Git continuously. This ensures that even quick declarative or UI based changes to Workflows or Fields get added into the Git repo. This happens whether it’s a sandbox or production. And it’s crucial because it allows Git to do it’s job. Without automatic syncing you might have certain types of metadata slip through the cracks.

Resolved Merge Conflicts with 1 Click

If a change occurs in two connected orgs, Blue Canvas will detect this and notify you when you try to merge the branches.

Blue Canvas even includes a slick user interface for handling the merge conflict. It will show you what is present in each org and let you quickly select which version you want to use with the click of a button (or custom edit the file if you prefer). This works with both code and declarative changes:

You can then resolve these conflicts and continue with your deployment.

Move Faster with Merge Conflict Detection

Automatic merge conflict detection allows
Salesforce developers to move much faster. When you trust your source control and CI system to catch merge conflicts, you can drop the spreadsheets and focus on actually building great tools. To gain access signup at https://bluecanvas.io.

Signup to get blog posts about Salesforce development, source control and Continuous Integration every week.