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.