How Git can solve workflow problems for Salesforce developers using Apex, Visualforce, and Lightning.
This article will walk you through the rapid adoption of Git as the gold standard in Source Control Management (SCM), through its unique features and benefits for collaboration. We will also cover Git's role in the Salesforce ecosystem, and the supportive tools that can extend the experience for Salesforce developers and admins.
Here are our 5 Key Takeaways:
Git was created out of frustration with existing SCMs and has become the de facto standard in the industry. Key features of Git include fast patching, offline work capability, and a distributed structure that supports efficient collaboration. Git helps to prevent "code clobbering," a common issue in Salesforce development, by abandoning a linear development workflow. Git improves the code review process with its diffing tools and rollback feature, ensuring high-quality releases. Tools like SourceTree provide a user-friendly graphical interface for working with Git, expanding its accessibility.
Linus and Git Why does it seem that so much of the best software gets built in a weekend?
In April 2005, Linux creator Linus Torvalds was frustrated with the proprietary source control tool (SCM) that Linux kernel developers had been using – BitKeeper. However, there were no other distributed SCMs that met their needs.
Legend has it that Torvalds went off one weekend and started addressing the problem head on. The next week he returned triumphantly with Git. An open source SCM with three simple criteria :
Patching should take no more than 3 seconds - as opposed to 30 seconds on other systems The new tool should support for a distributed workflow The new tool should Include safeguards against corruption Torvalds says that it actually took him about 10 days to finish creating Git , but within a day he was able to commit to Git using Git.
GitHub In 2008, Tom Preston-Werner, Chris Wanstrath and PJ Hyett teamed up to create GitHub - an online service for hosting Git repositories. The result was sensational. By February 2009, there were 46,000 public repos hosted on GitHub .
The success of Git with GitHub led others to follow suit and now there are a number of tools for hosting your Git repositories online (GitLab , Bitbucket ).
Today, Git has emerged as the dominant player in SCM today. It’s even called a de facto standard by companies like Atlassian . Large and small teams across the world now use Git to manage their code.
What Makes Git So Awesome? Git became popular because it was a vast improvement on previous SCMs.
GIT IS FAST Written in C, you’ll notice that patches take less than a few seconds. This was a key part of Torvalds’ original vision. Patches on previous SCMs took 30 seconds or more.
GIT LETS YOU WORK OFFLINE With Git you don’t need to be connected to the source code host in order to do work. This was not the case with many other SCMs around before Git showed up on the scene.
GIT IS DISTRIBUTED Source control can get messy if you have large commits with lots of code changes. Git encourages small frequent commits related to just one feature. It’s much easier to merge commits that pertain solely to one feature rather than a large commit that touches several features. This is what makes Git such a great tool for collaboration.
COLLABORATION Collaboration with Git is very simple. Tools like GitHub have made Pull Requests a standard part of any developer’s workflow. It’s easy to track changes and do code reviews with Git’s diffing tools. This makes it easy for large teams to collaborate on software projects without colliding or clobbering each other’s code.
BACK UPS Every clone of your repo serves as a working copy. Rolling back to previous states in your repo is also supported by Git. So you can always have confidence that your repo is in a good state.
.ap3w-embeddable-form-6491c5ce2060226781d5c909{box-sizing:content-box;width:100%;font-size:16px;max-width:850px;max-height:100%;overflow:auto;background-color:#f4f6fb;border:2px solid transparent;box-shadow:0 0 10px 3px rgba(0,0,0,0);z-index:unset}.ap3w-embeddable-form-6491c5ce2060226781d5c909:before{content:' ';display:block;position:absolute;pointer-events:none;left:0;top:0;width:100%;height:100%;opacity:0%;background-image:url();background-position:center center;background-size:cover;background-repeat:no-repeat}.ap3w-embeddable-form-content{margin:auto;padding:32px}.ap3w-embeddable-form-6491c5ce2060226781d5c909-rounded{border-radius:12px}.ap3w-embeddable-form-6491c5ce2060226781d5c909 .ap3w-text{margin-bottom:16px}.ap3w-embeddable-form-6491c5ce2060226781d5c909 .ap3w-text *{padding-bottom:5px}.ap3w-text-6491c5ce2060226781d5c909{position:relative;margin:0;margin-bottom:16px;word-wrap:break-word}.ap3w-text-6491c5ce2060226781d5c909 *{margin:0;padding-bottom:8px}.ap3w-text-6491c5ce2060226781d5c909 p{text-transform:unset;text-decoration:unset;text-indent:unset}.ap3w-text-6491c5ce2060226781d5c909 p[data-size="h1"]{font-family:Hind,Helvetica;font-size:30px;line-height:1.2;color:#433efe;font-weight:700;font-style:normal}.ap3w-text-6491c5ce2060226781d5c909 p[data-size="h2"]{font-family:Hind,Helvetica;font-size:20px;line-height:1.2;color:#433efe;font-weight:700;font-style:normal}.ap3w-text-6491c5ce2060226781d5c909 p[data-size="h3"]{font-family:Hind,Helvetica;font-size:20px;line-height:1.2;color:#433efe;font-weight:700;font-style:normal}.ap3w-text-6491c5ce2060226781d5c909 p[data-size="h4"]{font-family:Hind,Helvetica;font-size:16px;line-height:1.2;color:#433efe;font-weight:700;font-style:normal}.ap3w-text-6491c5ce2060226781d5c909 p[data-size="h5"]{font-family:Hind,Helvetica;font-size:14px;line-height:1.2;color:#433efe;font-weight:700;font-style:normal}.ap3w-text-6491c5ce2060226781d5c909 p[data-size="h6"]{font-family:Hind,Helvetica;font-size:14px;line-height:1.2;color:#433efe;font-weight:700;font-style:normal}.ap3w-text-6491c5ce2060226781d5c909 p{font-family:Hind,Helvetica;font-size:16px;line-height:1.2;color:#333333;font-weight:400;font-style:normal}.ap3w-text-6491c5ce2060226781d5c909 p[data-size="large"]{font-family:Hind,Helvetica;font-size:20px;line-height:1.2;color:#333333;font-weight:400;font-style:normal}.ap3w-text-6491c5ce2060226781d5c909 p[data-size="small"]{font-family:Hind,Helvetica;font-size:14px;line-height:1.2;color:#333333;font-weight:400;font-style:normal}.ap3w-text-6491c5ce2060226781d5c909{position:relative;margin:0;margin-bottom:16px;word-wrap:break-word}.ap3w-text-6491c5ce2060226781d5c909 *{margin:0;padding-bottom:8px}.ap3w-text-6491c5ce2060226781d5c909 p{text-transform:unset;text-decoration:unset;text-indent:unset}.ap3w-text-6491c5ce2060226781d5c909 p[data-size="h1"]{font-family:Hind,Helvetica;font-size:30px;line-height:1.2;color:#433efe;font-weight:700;font-style:normal}.ap3w-text-6491c5ce2060226781d5c909 p[data-size="h2"]{font-family:Hind,Helvetica;font-size:20px;line-height:1.2;color:#433efe;font-weight:700;font-style:normal}.ap3w-text-6491c5ce2060226781d5c909 p[data-size="h3"]{font-family:Hind,Helvetica;font-size:20px;line-height:1.2;color:#433efe;font-weight:700;font-style:normal}.ap3w-text-6491c5ce2060226781d5c909 p[data-size="h4"]{font-family:Hind,Helvetica;font-size:16px;line-height:1.2;color:#433efe;font-weight:700;font-style:normal}.ap3w-text-6491c5ce2060226781d5c909 p[data-size="h5"]{font-family:Hind,Helvetica;font-size:14px;line-height:1.2;color:#433efe;font-weight:700;font-style:normal}.ap3w-text-6491c5ce2060226781d5c909 p[data-size="h6"]{font-family:Hind,Helvetica;font-size:14px;line-height:1.2;color:#433efe;font-weight:700;font-style:normal}.ap3w-text-6491c5ce2060226781d5c909 p{font-family:Hind,Helvetica;font-size:16px;line-height:1.2;color:#333333;font-weight:400;font-style:normal}.ap3w-text-6491c5ce2060226781d5c909 p[data-size="large"]{font-family:Hind,Helvetica;font-size:20px;line-height:1.2;color:#333333;font-weight:400;font-style:normal}.ap3w-text-6491c5ce2060226781d5c909 p[data-size="small"]{font-family:Hind,Helvetica;font-size:14px;line-height:1.2;color:#333333;font-weight:400;font-style:normal}.ap3w-form-input-6491c5ce2060226781d5c909{position:relative;margin-bottom:20px}.ap3w-form-input-6491c5ce2060226781d5c909 input{margin-top:8px;box-sizing:border-box;width:100%;background-color:#FFFFFF;border:1px solid #000000;color:#000000;outline:none;font-family:Hind,Helvetica;font-weight:400;font-style:normal;font-size:16px;line-height:1.2;padding:10px 16px;resize:none;border-radius:4px}.ap3w-form-input-6491c5ce2060226781d5c909 .ap3w-form-input-label{font-weight:bold;color:#000000;font-family:Hind,Helvetica;font-size:16px;line-height:1.2}.ap3w-form-button-6491c5ce2060226781d5c909 button{position:relative;cursor:pointer;padding:10px;font-weight:bold;outline:none;border:2px solid transparent;color:#ffffff;background-color:#01b272;font-family:Hind,Helvetica;font-size:16px;line-height:1.2;border-radius:4px;flex:1}
Git and Salesforce As we discussed in a previous post, there are some significant issues with source control and deployments on the Force.com platform . Git is especially useful for Salesforce developers.
One of the major frustrations for Force.com developers is code clobbering . This is when one developer’s code overwrites another’s.
Git abandons the linear development workflow that is common with centralized version control systems. In a linear workflow, developers are working on the same code base at the same time. This causes problems where commits related to one issue are interspersed with commits related to other issues. When it comes time to release, this becomes a problem because not every feature is stable enough for a release.
This is also a problem when you have a broken build. Salesforce requires that 75% of Apex code be covered by unit tests. This is a great thing. However, if you are doing linear development, a broken build means that all developers will be unable to continue doing their work, causing mass consternation and unproductive time.
Git solves the problems associated with a linear workflow with branching and merging.
Git allows you to keep a stable master branch that is always deployable. Feature development happens on isolated feature branches. These feature branches are then only merged into the master code base once all tests are passing, keeping the team moving and happy.
Diffs, Code Reviews and Rollbacks Another nice feature of Git for Force.com is that it vastly improves the experience around code diffs. Git keeps a running history of all the changes that you’ve made with your code so that you can always keep track of changes over time. This is especially useful when trying to debug or understand an issue that may have slipped through to production.
Tools like GitHub, Bitbucket and GitLab all have excellent UIs highlighting diffs.
Code diffs makes code reviews, an emerging software development best practice, much easier to perform. Before any code is merged into the master branch more and more teams are requiring mandatory code reviews. This helps keep the quality of your releases high. Git makes it simple.
Git also makes it easy to rollback to a previously stable version of the code base at any time.
SourceTree Git is an incredibly powerful tool and has taken it’s place at the top of the SCM ladder. Most popular developer tools/IDEs have excellent support for Git. There are a number of great tools out there for learning Git. In addition to the cloud hosted Git repo services like GitHub and Bitbucket, there are tools like Atlassian’s SourceTree .
SourceTree is a graphical user interface for working with Git. It let’s you get all the power Git without having to touch the command line.
Moving faster, more safely with Git Using Git for Force.com development is a must. Salesforce developers that are doing so are seeing faster releases, less downtime, fewer manual errors on deploys, and better collaboration between team members.
Blue Canvas offers the benefits of Git-based development to the Salesforce community, while removing any headache of configuration or setup. Our Git-based solutions handle Version Control , backups and continuous integration, so your Developers and Admins can stay focused on shipping great features together! If you haven't tried it yet, sign up for a free trial at https://accounts.bluecanvas.io/signup . Just connect your orgs, compare them in seconds, and speed up your deployment workflow thanks to Quick Sync!