Nav
You are viewing an older version of this section. Click here to navigate to the latest version.

Using Git with Studio

Git facilitates the tracking and versioning of changes developers make to a software project; this enables several people to work on the same project, while preventing their changes and additions from coming into conflict.

Studio enables you to work with Git in two ways:

  • You can save your Studio project to a Git repository

  • You can import your existing projects from Git into Studio.

To move projects between Studio and Git, you must first install a Git’s Egit plugin in Studio.

Installing the Git Plugin

  1. In Studio, click the Help menu, then select Install New Software…​

    help

  2. In the Work with field of the Available Software panel, use the drop-down menu to select

    Egit Update Site - http://download.eclipse.org/egit/updates-2.1

    egit_site

  3. In the table below the Work with field, click the check boxes associated with Eclipse Git Team Provider and JGit.

  4. Click the expand arrow to the left of both Eclipse Git Team Provider and JGit and in the submenus that appear, then click to *DESELECT*the following three items:

    • EGit Mylyn

    • Eclipse EGit - Source

    • Eclipse JGit - Source

      egit

  5. Click Next to continue.

  6. In the Install Details panel, click Next to continue installation.

  7. In the Review Licenses panel, select I accept the terms of the license agreement, then click Finish. Mule .

  8. After Mule has installed the Egit plugin, click Restart Now to complete the installation and restart Studio.

    restart

Saving a Studio Project to Git

You can create a Git repository so that multiple developers can save changes to a Studio project in one shared location. To do so, you must first create and register a Git repository.

Creating a Local Repository

  1. In the Package Explorer, right click the name of your project, go to Team, then select Share Project…​.

    team_share

  2. In the Configure Git Repository wizard, click Create…​.

    configure_git_repo2

  3. In the Create a Git Repository panel, click Browse then navigate to the git folder on your local drive.

  4. Create a new folder for your new Git repository, then click Open.

  5. Enter a name for your new Git repository in the Name field.

    name_repo2

  6. Mule populates the fields in the Configure Git Repository panel to correspond with the folder you created for your new Git repository on your local drive. Check the box next to your project’s line item in the list, then click Finish.

    checked_line_item

  7. In the Mule Studio Package Explorer, notice the small question mark icon that appears next to your project name (below). This icon indicates that you have created a Git repository for your project on your local drive, but you have not yet registered it and are not yet tracking changes to the project.

    question_with_arrow2

Registering a Local Repository

  1. In the Package Explorer, right click the name of your project, navigate to Team, then select Commit…​.

    If you have not yet identified yourself to Git as a user, the Identify Yourself panel may appear at this point. Enter a User name and User e-mail that Git can use to identify you and the commits that you make to your Git repository.

    identify_yourself

  2. In the Commit Changes panel, commit the inaugural version of your Studio project which will effectively register the project on your local drive. In the Commit message field, enter a description of the project you are about to commit to the repository. (In the future, when you commit changes to the project to your repository, use the Commit message field to record the changes that you have made to the project since your last commit.)

    commit_changes

  3. In the Files pane, notice that Mule has applied a question mark icon to each of the items in the list. This icon indicates that the file is "untracked" in Git (i.e. the file has not yet been saved in the repository). Click the checkbox next to each item to select all of them.

    files_2

  4. Click Commit to save your project in your new Git repository.

  5. In the Package Explorer, notice that Mule applies a barrel icon to your project name (below). This icon indicates that you have committed this project to a Git repository.

    barrel_with_barrel

Committing Changes to the Local Repository

After making changes to your Studio project and saving in Mule, you can commit changes to the project in your local Git repository.

  1. First, save the changes you have made to your Studio project in Mule (File > Save).

  2. In the Package Explorer, notice that Mule applies a chevron in front of your project name (below). This icon indicates that you have made changes to your Studio project but have not yet committed those changes to your Git repository.

    with_chevron2

  3. In the Package Explorer, right click the name of your project, go to Team, and select Commit…​.

  4. In the Commit message field of the Commit Changes panel, enter notes to describe what you have added or changed in the Studio project.

    commit_changes_remote_2

  5. Click the box next to all items listed in the Files pane, then click Commit to save your changes to your local Git repository.

Committing and Pushing to a Remote Repository

When multiple people work on a Studio project, they must all synchronize changes through the a remote Git repository. Within Studio, you can push your latest commits to a project to the remote Git repository.

This procedure assumes that you have already created, and have read-write access to a shared remote Git repository, and that you have SSH access to the virtual private server (i.e. the Git server).
  1. If your project is already being tracked on a remote Git repository, you must first Cloning and Pulling from a Remote Repository of your project from the remote repository before proceeding to step 2. This ensures that the commits you are about to push contain all the project changes that others have previously committed to the remote repository.

  2. Follow the steps above to commit your changes locally.

  3. In the Package Explorer, right-click the name of your project, navigate to Team, then select Push to Upstream.

  4. Mule pushes your commits to the remote Git repository, then presents a Push Results panel that describes the commits you have pushed. Click OK.

    push_results

Importing a Git Project into Studio

You may wish to access a project in a Git repository, then import it into Studio so as to leverage Studio’s graphical user interface. To do so, you must clone, then pull the project from your Git repository.

Studio offers two ways to import a project from a Git repository:

  • If you have already cloned your Git repository and stored it on your local drive, follow the procedure for Importing a Project from a Local Drive.

  • If you have not yet cloned your Git repository and stored it on your local drive, follow the procedure for Importing From a Remote Repository

Importing from a Local Drive

This procedure assumes that you have already created a local Git repository (and have imported it into the Eclipse workspace if you created it manually, without a wizard), and that you have saved to that repository the project you wish to access in Studio. Further, your imported project must contain a .project file, a .classpath file, and a .settings folder before you can open it in Studio.
  1. In Studio, under the File menu, select Import…​.

  2. In the Import wizard, click the expand arrow next to the Git folder, then select Projects from Git.

  3. Click Next to continue.

    proJ_from_git_cropped

  4. In the Import Projects from Git wizard, select Local, then click Next.

  5. Click to select a Git repository from the list of repositories on your local drive, then click Next.

  6. Select Import existing projects from the list of import methods, then click to select the Working Directory folder

  7. Click Next.

    project_import

  8. Use the drop-down menu in the Working sets field to select the project you wish to import, then click Finish.

  9. Known Issue: Under the Projects menu, select Clean…​ to scrub the project and ensure that Studio has created a consistent build path.

    clean

  10. Under the File menu, select Open…​, then navigate to the cloned repository on your hard drive to open your project and work with it in Studio.

Importing From a Remote Repository

This procedure assumes that you have already created (and have read-write access to) a shared remote Git repository; that you have SSH access to the virtual private server (i.e. the Git server); and you have saved to that repository the project you wish to access in Studio. Further, your imported project must contain a .project file, a .classpath file, and a .settings folder so that you can open it in Studio.
  1. In Studio, under the File menu, select Import…​.

  2. In the Import wizard, click the expand arrow next to the Git folder, then select Projects from Git.

  3. Click Next to continue.

    proJ_from_git_cropped

  4. In the Import Projects from Git wizard, select URI, then click Next.

  5. In the URI field, identify your user name and the name of your Git repository. Use the following format to enter the information: git@github.com:username/repository-name.git. When you enter this information, Studio automatically completes the remaining required fields in the panel.

    URI_location

  6. Click Next.

  7. In the list of branches in your Git repository, click the boxes next to the branch (or branches) of your project that you wish to check out and work on in Studio.

  8. Click Next to continue.

  9. Select the directory on your local drive to which you want to clone and save your project, then click Next. Git clones the branch(es) you selected and stores them on your local drive.

  10. Select Import existing projects from the list of import methods, select the Working Directory folder, then click Next.

    project_import

  11. Use the drop-down menu in the Working sets field to select the project you wish to import, then click Finish.

  12. Known Issue: Under the Projects menu, select Clean…​ to scrub the project and ensure that Studio has created a consistent build path.

    clean

  13. Under the File menu, select Open…​, then navigate to the cloned repository on your hard drive to open your project and work with it in Studio.

Cloning and Pulling from a Remote Repository

For multiple people to collaborate on a Studio project, everyone must synchronize their changes through a remote Git repository. To work on your project locally within Studio, clone, then pull the latest version of a project from a remote Git repository.

This procedure assumes three things:

  1. You have already created (and have read-write access to) a shared remote Git repository

  2. You have SSH access to the virtual private server (i.e. the Git server)

  3. You have previously Importing From a Remote Repository into Studio

  1. In Studio, click the (error) icon next to the Flow tab to close all the Message Flow tabs of the project you are about to pull from your remote Git repository.

    close_flow

  2. In Package Explorer, right-click the name of your project, navigate to Team, then select Pull…​.

  3. Mule pulls the project from the remote repository, then it presents a Pull Result panel that describes the changes others have made to the project since your last pull.

  4. Click OK.

    pull_results

  5. In Package Explorer, double-click the name of the flow(s) in your project to reopen them on your Studio canvas.