How to push Mule project to GIT

Introduction

Nebiha

Last Update 4 years ago

Git is a free and open-source distributed version control system that is designed to protect your data between versions, and enable developers to share changes to their code cross-organizationally. Git and Anypoint Studio combined is powerful when you are working on a team where you will need to track changes made to integrations developed in Anypoint Studio. In this tutorial, learn how to set up the EGit Plugin which allows you to commit, clone, pull and push to repositories directly from inside the Anypoint Studio IDE.

Initial Commit to the Git Repository

Anypoint Studio 7.5 + version has git plugin packaged with Studio installation which means that you no longer need to install the Egit plugin. Using Egit plugin you can:

  • Synchronize your API specification with Design Center
  • Check-in your code to git repositories
  • You can clone an existing Git repository.
  • Create Git repositories and more.

Initial Commit to Local and remote repository: As a part of a team of developers, you may be using an SCM (Source Code Management) tool such as git to keep track of changes in an application, you will need to create a repository in a shared location on Git to check-in your Mule application code from Studio so other developers can collaborate.

To create a local repository, In the Package Explorer, right-click the name of your project → select Team → select Share Project

In the Configure Git repository window, Select the checkbox for Use or Create a repository in the parent folder of the project. (Note: Using this method you will make sure that the .git folder is created in your project root and not your parent folder.)

Click on the Create Repository button and then finish

In the Anypoint Studio package explorer, you can see the arrow mark and questions mark symbols for your studio files. 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.

Now you need to register the local repository and track changes. To do this go to your package explorer, right-click to the name of your project → select Team → select Commit

Once you have clicked on the Commit button. You will see the Git Staging tab opened up. Select all the files that you want to check-in in Git then right-click on the selected files and click on Add to index. 

Add a commit message to the text box and click on the ‘Commit’ button. Your changes will be stored in the local git repository.

In the package explorer, there is a yellow barrel icon which indicates that the changes have been committed to your local git repo. Also, there is no more arrow icon next to the project name.

Next, commit to your remote git repository. In the Package Explorer, right-click the name of your project navigate to Team → select Remote → Push

Login to Github.com or an appropriate system like Gitlab, AzureDevOps etc. where you have the Repo created and copy the remote repository HTTPS URL to clone in your clipboard.

Paste the URL of the empty repository created in Remote Git. If you do not havetoken authentication enabled for your Org in GitHub. Use Basic authentication and enter the username and password for your USER ID.

Paste the URL of the empty repository created in Remote Git. If you do not havetoken authentication enabled for your Org in GitHub. Use Basic authentication and enter the username and password for your USER ID.

If you have two-factor authentication enabled for your Org then you are required to use the token-based authentication. (According to this blog post you will have to use tokens for authentication even for a Git repository on GitHub.com after H2 of 2021).

First, go to https://github.com and log in, now you can see your profile image in the top right corner. Select the Settings menu under your profile image at the top right of the screen.

Go to the Developer Settings button at the left under Account Settings. Choose Personal Access Tokens then hit Generate new token button to create one. Now give the token a description. Define the access scope for the token and then copy the generated token. You can then paste the token into the password field.

Select the Specification for Push from the Source ref and Destination ref and then Click on Add Spec, then Click on Finish.

After the changes are committed to the remote repository you will see a window which will indicate that the changes are pushed successfully which is similar to the window below. Click on 'OK'.

After the changes are committed to the remote repository you will see a window which will indicate that the changes are pushed successfully which is similar to the window below. Click on 'OK'.

After the changes are committed to the remote repository you will see a window which will indicate that the changes are pushed successfully which is similar to the window below. Click on 'OK'.

You have Successfully committed your changes to the remote repository in Git 


Was this article helpful?

1 out of 1 liked this article