There’s been some confusion lately within my network about how to setup MavensMate, Github, and Salesforce so that they all hold hands together.
What does this look like? I want a MavensMate project folder that doubles as a local Git project folder.
I’m documenting this process internally and since there seems to be very little documentation online about this, I’m hoping that sharing this publicly will help give back to the community.
I’m making several big assumptions here.
- You’ve installed Sublime Text 3 & MavensMate & configured your preferences (specifically project folder);
- You’ve installed MavensMate Desktop;
- You’ve installed SourceTree & configured your preferences (specifically project folder);
- You have a Github account (or an account on another Git option);
- There’s an active repository you’re looking to connect to;
- You’ve authenticated SourceTree to your Git repo; and
- You’re running Windows, because they haven’t given me my Mac yet.
In your preferences for each, you should now have both MavensMate and Sourcetree project folders pointing to the same directory (if you don’t, why are you here? This is the entire point!)
Further, a “how to use Git” tutorial is out of scope for this article. Got it? Cool! Let’s get started.
First we’ll focus on MavensMate. Open MavensMate Desktop and select Create New Project. Select your URL type, and enter the URL. Click the blue Connect button.
You’ll be asked to authenticate your project. Authenticate.
In the Project Details tab, give your project a name (I’m calling mine “DBE”). In the Project Metadata tab, select all the Metadata types you wish to subscribe to. When finished, click the blue Create Project button.
Close MavensMate Desktop. In Windows Explorer, navigate to your project folder. Look for the “DBE” folder you just created from your Salesforce environment. Rename this folder to “zDBE” for easy access later.
Open SourceTree. In the ribbon, click the Clone / New button.
In your browser, log into Github and navigate to your repo. Click the Clone or download button, and copy the URL to your clipboard by clicking the highlighted button below:
Come back to SourceTree. Paste that URL into the Source Path / URL field. Destination Path and Name should fill in automatically. NOTE: Make sure the Destination Path is the full path of the former name of the MavensMate project folder you just renamed.
Click the Clone button and wait for the import to finish.
4. Holding Hands
Now we need to employ a little trick to get the different programs to work from the same folder. First, close SourceTree. Then go back to your Windows Explorer and make a backup of your DBE folder. I called mine “gitDBE”. This will serve as a backup so if I screw something up, I don’t have to start from the top of these instructions.
Navigate to zDBE folder. Select everything* and select copy. Navigate to your DBE folder and paste everything on top. Overwrite everything.
Open up Sublime Text 3. It probably pre-loaded a project, but we want to be absolutely sure this folder acts as a MavensMate project. In the file menu, select File > New Window. Close the window with the loaded project.
In the new (blank) window, from the menu select MavensMate > Project > Open Project… Select the DBE project. The project should open fine from the git project folder. (If DBE is not in the list, you’ve done something wrong. It’s a good thing you took that backup of the git project folder!)
Close Sublime Text 3. Open Source Tree. Your project should also load from the DBE project folder in Source Tree as well.
Congratulations! You now have a folder that acts as both a Source tree project folder and as MavensMate project folder that is also connected to your Salesforce sandbox.
*NOTE: You may find yourself in Source Tree with a bunch of uncommitted files. This could be because because of different reasons:
- Your SFDC environment is multi-tenanted with different apps, while your Git repo isn’t;
- You’re subscribed to more metadata in MavensMate than was checked into git;
If this is the case, all you really need to copy over is your project folder’s .sublime-project and .sublime-workspace files, and the config file. You may also have to configure your repository’s .gitignore file to ensure the following are ignored:
And if other contributors to the project are using different OS systems, or different IDEs, you’ll have to add those relevant files to the .gitignore file as well.