10

I'm trying to clone a github repo and then connect it to my dev org. I've tried to do this several different ways with Mavensmate in Sublime Text and none seem to work for me.

I tried just creating a new project, selecting no metadata, and received the following error: module object has no attribute get_password_by_project_name.

I also tried following this method: http://mavensmate.com/Plugins/Sublime_Text/Existing_Projects

and received this error: project with this name already exists in your workspace

Has anyone had success with this?

  • 1
    I was just helping a coworker with this and it looks like he didn't have his mm_workspace types in correctly in the MavensMate settings. It is case sensitive. Once we fixed that, the project could be created. – Daniel Hoechst Apr 8 '14 at 13:22
  • Just to add to Daniel's comment, I had to omit the trailing directory separator i.e. /users/username/mm_workspace rather than /users/username/mm_workspace – GBreavin Feb 4 '15 at 1:58
  • I have setup my repo+mavensmate combo the way you have outlined here. Now, making individual changes and saving them to the sandbox works nicely, but I want to baseline the sandbox with the code from repo. I was hoping that a mavensmate deploy would pick up the files from the local repo folder and push to sandbox, but it does nothing, since the 'Project Metadata' section in MavensMate shows just a 'null' checkbox. Have you come across this issue? How did you manage to baseline your sandbox from the repo? – Shankar Mar 21 '17 at 15:24
7

I do this all the time. Here's what I do:

  1. Make sure the repo doesn't include certain files and folder. Here's my .gitignore:

config/ *.sublime-project *.log deploy/ debug/

  1. Clone the repository using your favorite Git client (I use Source Tree).
  2. Open the containing folder in Sublime
  3. Right click on the folder to create a MavensMate project and connect it to your sandbox. (http://mavensmate.com/Plugins/Sublime_Text/Existing_Projects)
  4. Optionally, use Ant to deploy the entire metadata to the sandbox or just save piecemeal as you need.
  5. Make changes and commit!
  • I think there might be an issue with the windows version if I clone the project directly into my workspace. Are you using a Mac? I'm doing some hacky workaround right now. – Phil B Dec 20 '13 at 17:03
  • Nope, I do the same thing from both Windows and Mac. – Daniel Hoechst Dec 20 '13 at 21:37
  • Have you tested cloning the repo into your working directory? – Phil B Dec 22 '13 at 22:23
  • I clone into workspaces/mavensmate – Daniel Hoechst Dec 23 '13 at 4:03
  • Very weird, I wonder what I'm doing differently then. I'm trying to figure it out with a github issue. While I have you, do you ever get 'cannot update a sandbox copy of a package' errors while trying to push the latest from the local git repo to the sandbox? – Phil B Dec 23 '13 at 19:20
5

I documented this but it's been some time since I've revisted these steps. Also note that my team uses Git Tower. See if this is helpful to you:

  • Before you begin, make sure that you don’t have any work in progress, that the latest and greatest everything your team has been working on is committed to Git and pushed up to Github.
  • Follow the instructions for setting up your new project in Sublime / MavensMate if you haven’t already but instead of choosing Metadata, make sure all metadata is deselected.
  • In your project workspace in Sublime, you should have an empty Src folder with the exception of package.xml
  • Open Tower
  • From the Repositories drop-down on the top right, click on Manage Repositories Click on the Create Local Repository button
  • Browse to the root level of your project workspace in your Sublime workspace. For XXXXXXXXXXX for example, You would select the XXXXXXXXXX folder, which contains the Src folder and other project metadata files and directories. Give you project a name, mirroring the name of your project is recommended but not required. Click the Ok button.
  • Double-click on your new project that should appear in the repositories list.
  • Right click on the Remotes submenu in the sidebar or go to the Refs menu and click Add New Remote Repository. Give it a name, I recommend what its named in Github but that’s not required. Paste the HTTP link from Github into the Repository URL field and then enter your Github Username and Password and click the Add button.
  • In your Status tab, there should be a handful of untracked changes, indicated by question marks next to files and directories. Ignore these for now. For existing Salesforce instances, that closely mirrors what is in your Github repository, skip to Step 12. For new Salesforce instances, that does not mirror what is in your Github repository, follow these instructions:
  • Clean out your instance.
  • Delete all of the bogus custom buttons and fields that get added to new developer instances
  • Delete all of the Visualforce pages and Apex controllers that may have gotten added from activating Sites, for example.
  • Try to set all of the settings, and there are a ton of little ones here like whether or not Social Contacts is enabled, as closely as you possibly can to the original Salesforce instance tied to the Github repository.
  • This is a necessary nightmare and may require looking at the diff logs and back to your Salesforce instance's settings a few times before getting it dialed. The reason for this clean out is so that when you're working with a distributed team, who are connected to different dev environments, that your environments looks the same and you team isn't constantly committing new changes that are just environment factors and not real changes that require version control. The last thing your team wants is to have to worry about stupid tag changes on custom objects that they have to decide whether or not it is relevant.
  • In Tower, setup tracking on the branches you want to work on by right clicking on the branches listed under Remotes and clicking Track This Branch.
  • Checkout the branch in your local repo to make it the HEAD (working directory) by double clicking on the tracked branch under the Branches submenu.
  • You can now pull down your remote files from Github by clicking on the Pull button. If you want other branches, select that option, and use Rebase.
  • You should get an error message on the pull indicated that you will overwrite some untracked changes. This is safe to ignore.
  • Now, check your status tab and behold a bunch of new changes, suggested deletions. Git is confused, it thinks your local copy of this data is more current than what is in Github and locally you have nothing in your Src folder so it thinks you want to now delete everything from version control. Silly Git.
  • Select everything in the Status tab, all files and directories and Stash it by clicking on the Working Copy menu and Save to Stash. Call it something like “Initial project setup, NEVER USE” or something along those lines.
  • Anything left after stashing probably needs to be added to gitignore. Right click on these files or directories and Ignore “XXXXXXX” . Make sure the option to only ignore locally is not selected if you want others accessing the repository to also have these files ignored (usually always the case).
  • Commit these additions to .gitignore by selecting that file, clicking on the Commit button. Add a helpful commit message and push to the remote by clicking on the Push button.
  • If this is a new Salesforce instance that has never had this fancy new metadata from Github, then you need to get it from your local filesystem into Salesforce. To do this, open your project in Sublime, click on the MavensMate menu then Project > Compile Project. This is the equivalent of selecting the Src folder in Eclipse and from the Force.com menu Save to Server, except less dirty.
  • (Error Handling)
2

I am wondering if it is easier to install the git repo directly in the Dev Org, and then generate the project that way. Andrew Fawcett wrote a tool that lets you install a repo directly from Git...

  • I've seen this and it would be a cool option if it was a public repo. – Phil B Dec 19 '13 at 22:00
  • You can use this tool with private repos too. – Luc Boissaye Apr 27 '17 at 11:27
1

We're now in 2017. Mavensmate is already somewhere in v7 and the desktop app is somewhere in version 0.0.10. Here's how it's done now for the sake of devs like me searching for enlightenment:

  1. Clone your repo inside your mm_workspace
  2. Open sublimetext
  3. Click File > Open Folder
  4. In your sidebar (make sure your side bar is visible. toggle it using Ctrl+K,Ctrl+B), right click on the root folder, click MavensMate > Create MavensMate Project...
  5. Your mavensmate app will open up. Just press the big blue button in the upper right that says "Create MavensMate Project".
  6. That's it.
  • SamuelDev tried what you are suggesting and it creates says Directory already exists, not sure how you are doing step 5 and 6 – Shamanth Suresh Mar 21 '17 at 21:05
  • @ShamanthSuresh I'm not sure what's happening there. After successfully executing #4, your mavensmate app (which is supposed to be already open before you even started #1) will now open a new tab, and the tab's title would be "New Project From Existing Directory". In that tab, there are text boxes for the workspace, a grayed-out textbox for the directory name (already filled out with your desired directory), text boxes for uname and pwd, and a textbox for org type. After filling those up, proceed to #5. – SamuelDev Apr 4 '17 at 6:40

Not the answer you're looking for? Browse other questions tagged or ask your own question.