Integration of Bitbucket Repository and Mavensmate

January 12, 2018 Aditi Bhardwaj

This blog will discuss how to set up a local repository — a Mavensmate Project — associated to an existing sandbox, from where you can make a variety of changes locally. You will also be able to push them to branch on a Bitbucket cloud repository.

We’ll review  how to push changes that can branch out, just by adding a single component. After, add the package.xml into your Mavensmate project, and refresh the files from the server.

Follow these steps to integrate the Bitbucket repository with your Mavensmate Project:

  1. Clone your repository inside your Mavensmate workspace (mm_workspace).
  2. Open the cloned repository folder in Sublime.
  3. Create Mavensmate project.

Step 1: Clone your repository inside your mm_workspace

Go to Source treeFileNew/Clone ⇒ Click on Clone From URL

Note:  First create an empty folder in your Mavensmate workspace, and then select this folder as the destination folder for your repository. In your project workspace in Sublime, you should have an empty src folder, with the exception of package.xml.

Following Step 1, you can find Bitbucket files in your empty folder along with src:

Step 2: Open the cloned repository folder in Sublime

To open a folder in Sublime:

  1. Open SublimeGo to FilesOpenSelect folder name to openClick on Open.
  2. Right click on folder Mavensmate Select Create Mavensmate Project.


Step 3: Create Mavensmate project

  • Connect your folder with Mavensmate using the Mavensmate desktop app:

  • Enter credentials for your Salesforce org, and then click on Create Project.

Now that you know about the integration of Mavensmate and Bitbucket repository, you can open your folder as a Salesforce project in Mavensmate. You will be able to check your changes by adding a component in package.xml of the project, and then fetching the refreshed data from the server.

Let’s make some changes to the remote branch after committing them to our local system:

  1. In your Status tab of source tree, there should be a handful of untracked changes —  indicated by question marks —  next to files and directories. Ignore these for now.
  2. In the source tree, set up tracking on the branch you want to work on by double-clicking the branches listed under Remotes and Clicking.
  3. To commit your changes to the remote branch, you need to first check out the remote branch into your local repo to make it HEAD (working directory). While checking out branch into your local repo, please don’t forget to check “Local branch should track remote” checkbox, otherwise your local branch will not remain in sync with the remote one.
  4. You can now fetch remote files from Bitbucket by clicking on the pull button. If you want other branches, select those options and use rebase. You will get an error while pulling down changes from the remote option, which shows that you will overwrite some untracked changes. This is safe to ignore.
  5. Now check your status tab which contains a lot of new changes and suggested items to delete. These are the changes from your local system which you don’t want to commit.
  6. To remove those files, select everything in the status tab (all files and directories)and store them by clicking on the working copy, and clicking on stash. If we have anything left after stashing, we need to add them to gitignore. You can do this by right clicking on Files and selecting Ignore. Commit these files to gitignore by selecting Files and clicking on the Commit button with some commit message. After this, push to remote by clicking on the Push button.
  7. You should now be able to pull files from the remote branch. Once you get a fresh copy from remote, you can implement your changes on that copy. You are now able to commit those changes back to the remote branch.
  8. Add the component you want to modify into your package.xml and then refresh your project’s metadata using Mavensmate and Sublime.
  9. The files statuses in source tree reflect the modified files. Next, select the file and the hunk you want to stage, using the Stage Hunk button on the right hand side. You can also select lines by using the Stage Lines button, and then commit your changes to the remote branch with a meaningful commit message.

Note : Commit will only commit changes to your local copy. You need to push your changes to the remote branch. The Push button indicates the number of changes you are trying to push onto the remote branch. By clicking on the Push button, you can push changes to the remote branch.

Do you want to learn more about the world of technology and how it can be applied to your business? Subscribe to our new Resource Hub for updates on the latest topics around technology, working in the cloud, and customer and worker experiences.

Previous Article
Marketing Cloud Connect Is Installed — Now What?
Marketing Cloud Connect Is Installed — Now What?

As a follow-up to Installing Marketing Cloud Connect in Salesforce, I wanted to share suggestions that will...

Next Resource
What is DevOps?
What is DevOps?

A combination of practices and tools that automate development & IT processes to improve products at a fast...