|Applies to: Lightning and Classic|
As a developer, we understand the importance of using version control to track our code changes. Setting this up with Salesforce development may not be as intuitive as with other development tools so this post will walk you through how to setup Git within your Eclipse development environment.
First, go to the Git website, download and install the latest version. You may already have Git installed but this will insure you have the latest updates.
Now let’s get Eclipse setup. Open Eclipse and we’ll add some additional views that will allow us to monitor and manager the repositories.
Next lets setup a Git repository site. I prefer GitLab simply because it allows me to setup private repositories at no cost. GitHub is another option but their free repositories are publicly visible. Setup an account with either solution.
In GitLab, create a New Project. In GitHub, it’s New Repository. Name the repository the same as your Eclipse project. You don’t have to use the same name but I find it simpler when working with multiple projects.
I only setup repositories on my sandbox projects since code changes is all I typically track. However, if you’re wanting to track all metadata changes then create a Project that holds all metadata and you can setup a repository on it as well.
Copy your repository’s HTTPS UTI. You’ll need this in our next step.
Click back to Eclipse.
Your project is now setup with version control.
When you need to make code changes, simply open the code and make your changes as you would normally. You’ll notice the icons next to the project files will change to indicate files that no longer match the repository. The differences also show in the Git Staging view.
Once all the changes are complete and you’re ready to commit them to the repository:
If you return to your GitLab/GitHub website, you’ll see the changes in your repository.
For additional help, here is a good YouTube video that walks you through much of the Eclipse steps.
Finally, if you’re working with a team of developers, each team member will leverage the same Git Repository. To keep the local repository in sync with other teammates committed changes:
Hope you find this step by step guide helpful in setting up version control for your salesforce.com projects. If you have questions or additional suggestions, please ask.
That is awesome that companies that use Sales Force are able to compute their company on a cloud. I really like that Sales Forces seems to be a very organized and effective way to record your daily sales. Thank you for sharing the benefits of turning towards an online method of computer recording
Why not use a decent Git GUI like smartGit? Often one is not just wokring on one feature, but also fixes one or another minor bug. With smartGit you can stage individual pieces of code to be able to create clear-cut commits. IIRC, this is not possible with plain command line Git and saved my ass a lot of times. Give it a try and you never will use command line again for such common tasks.
Wow, thanks for the very informative article Terry! I have been able to git a repository created of all of our Salesforce metadata in Team Foundation Server on visual studio.com and everything works form the Git command line but I am having some problems in Eclipse/Force.com IDE. When I try to connect to the repo through Eclipse I get a ‘Not authorized’ error. I’ve tried several combinations of usernames passwords and tokens and nothing works. I have a few more ideas I am going to try but was just wondering if you had any thoughts or have seen this issue before.