Back To Blogs
Jarnail Singh 31st Jul 2023

Git integration in Mendix

Over the past decade, Git has become the overwhelming version control system favourite and a clear market leader over other popular version control systems, like SVN and Mercurial. It’s dominance is well documented and can be seen in this Stack Overflow 2022 Developer survey, where a whopping 96.65% of professional developer respondents said that they use Git as the primary version control system. With Git becoming the new standard, Mendix has committed the move towards Git version control and deprecated SVN in Mendix 10. In this blog we will explore some of the differences between using Git and SVN and walk through how developers use Git version control when creating both new applications and when converting existing Mendix applications.

Why move to Git over SVN and what’s supported?

Before diving into the how, let’s take a quick look at the reasons why Mendix has chosen Git as their standard for version control going forwards. To start, they are following in the footsteps of some renowned software companies, Git is the software version control standard for companies including Github, Azure, and AWS. There are also many other advantages which Git provides over SVN such as:

  • Less dependence on a high-speed internet connection. Git stores a local version of the repository, which means developers don’t need to synchronise their work as often.
  • Git provides developers with more control over what is being committed and when. With Git, changes can be committed without immediately pushing the changes to the central repository.
  • It’s faster and Git is more reliable when synchronising changes to and from the central repository.
  • With Git, you have to commit locally before retrieving any updates, which means if a mistake is made when resolving conflicts, you can still view the changes you and your colleagues made and resolve them, without having to fully merge your code with the server in order to see conflicts.
  • There is the option to use third-party Git tooling such as Github Desktop if you have the need to manage things more closely.

Support of Git is through the Mendix Team Server, the Mendix-hosted environment that stores all Mendix apps, and this is similar to the current SVN implementation. Alternatively repositories can also be hosted on a private server, which we will look at later on in this post. Team Server Git has been released for general availability in version 9.12.0. BYO-GIT (Bring Your Own Git) and has been in beta since Mendix version 9.6.0. As of Mendix version 9.24.0, it is only possible to use Git in the Mendix Team Server – it is no longer possible to create new applications using SVN for version control but you can still download existing SVN controlled applications. Let’s now take a look at some of the advantages of Git in more detail…

Using Git in Mendix Studio Pro

To access Git operations in Studio Pro, navigate to the version control menu at the top of the page (examples shown below for both an SVN and Git repository) :

In Git, the same operations as in SVN can be performed with some small changes. For example, during a commit in SVN, changes would first be pulled from the remote repository, these changes are then committed and pushed to the remote repository. However, in Git there are both local repositories and remote repositories. The difference here is that Git allows for better control when something needs to be pushed to the remote repository. When a commit is created, it will be added to the head of the current branch in the local repository and it is only when a push operation is performed that the changes will then appear on the remote repository. The result is that this provides far better versioning and control of changes. The disadvantage, and something to be mindful of, is that if changes are not regularly pulled or pushed, branches will diverge making merge conflicts a bigger risk and harder to resolve.

Another change for the better with Git is where merging is performed. In SVN, merges happen on the server side as soon as a commit is performed. However, with Git, merging can be performed when pulling, pushing or merging branch lines locally or on remote repositories. For this reason, managing conflicts is easier with Git as there is greater control over local change. If there are significant problems in the local repository, they can be overwritten by pulling the remote repository. Revisions are also tagged in different ways between the two. SVN will sequentially count between each version (1,2,3,4…) whereas Git will generate a hash for each commit. In Git these hashes can be referenced to perform operations such as checkout, cherry-pick or diff.

How to setup a new application and convert an existing application with Git version control

When creating a new application, the template and version control system are configurable for Mendix versions between 9.12.0 and 9.23.0. To use Git, after selecting the template, set the repository type to Git. Once selected, click the ‘Select Template’ button and Mendix will create both the app and the repository.

To convert an existing application’s repository to Git, navigate to the application in the Developer Portal. At the top of this page, a banner with the option to migrate to Git will appear. Clicking on ‘Migrate to Git’ will prompt you to check certain conditions to ensure that the repository is suitable for migration to Git. Once the prompt has been confirmed, clicking ‘Start Migration’ will start the process. Mendix will then migrate the repository and notify by email when the migration is complete.

Using Git with a command line interface (CLI)

Using a command line interface (CLI) such as GitBash will allow execution of more Git commands than what is available in Studio Pro, for example, cherry-picking and rebasing. By default, Mendix projects are stored in the $User/Mendix directory. Opening a terminal in the project directory will allow the use of Git commands. Changes made through CLI will not be reflected in Studio Pro immediately. The “Synchronise app directory” option will not circumvent this, and a complete restart of Studio Pro will be required.

When pushing/pulling via CLI, username and password credentials are required. The username is the account email address, but the normal password will not allow authentication. A personal access token (PAC) is needed. This can be obtained from the Mendix account settings, which can be accessed by clicking on the profile picture at the top right of the Developer Portal page and selecting ‘User Settings’ from the drop-down menu. To generate a token, navigate to Developer Settings and select ‘New Token’.  This will open a form. Give the token a relevant name and select the relevant options in the ‘Model Repository’ section. Select “Create” and a prompt will appear showing the new access token. In the terminal perform a pull to get the prompt for credentials and enter the username and password. If “Save Credentials” is selected, then the prompt for credentials will not appear again until the token is deleted or expired.

Version control for private repositories

Instead of hosting a project on the Mendix server, a private repository, such as GitHub, can be used instead. In versions 9.24 and above Private Git is now always enabled, so there is no need to enable it in the Studio Pro Preferences – see Studio Pro release notes for further info. In versions older than 9.24, in Studio Pro navigate to edit > preferences. Navigate to the version control tab and enable private repositories as shown below.

To host a project on a private repository, navigate to the “Version control” tab from the “Edit” and “Preferences” menu. Select “Upload to Version Control Server”, select private server and enter the repository address.

On GitHub the repository address can be found in the code dropdown on the repository itself. A personal access token is required to authenticate. In GitHub, under Profile settings > Developer settings, a token can be generated. Give this token a memorable name and repo access. Finally generate the token and copy the credentials.

Conclusion

Integrating Git into Mendix has expanded the tools available to developers for version control. It is a big improvement to SVN and will align practices in other platforms with Git being one of the most popular choices for software developers. Additionally, integrating Git allows the easy use of private repositories such as GitHub giving better control over codebases for Mendix users. Mendix will continue to leverage the power of Git to further improve the collaboration capabilities. For more support on migrating or upgrading apps, please reach out to us or check out the Mendix Version Control documentation for more information.

Related Blogs


Mendix low-code fundamentals – applying application security

Looking to ensure secure application development? Episode 3 of our Mendix Fundamentals Series describes how security rules can be applied and helps you understand the basic security principles within the Mendix low-code application development environment.

Find Out More

Mendix low-code fundamentals – building the pages of your application

Episode 2 features Mendix developer Luca Santese demonstrating how to build Pages and create an engaging front-end for your Mendix low-code application!

Find Out More

Mendix low-code fundamentals – creating the domain model

Our new Mendix Fundamentals Series contains explanations and walkthroughs of some of the key concepts used in the Mendix low-code development platform. Across the four-part series, AuraQ’s team of experienced Mendix developers will cover the essential features required to build an effective Mendix application including the domain model, pages, security and microflows.

Find Out More

Leveraging machine learning capabilities in application development

In recent years, the digital sector has been transformed by artificial intelligence (AI). With tools such as ChatGPT and DALL-E, public access to AI resources is at an all-time high.

Find Out More

From graduate to expert developer | Matthew Pratley’s Mendix journey

Ever wondered what it takes to reach Mendix Expert level? The Expert certification process is quite different from the other certifications (Rapid, Intermediate and Advanced) and is not only proof of a Mendix developers knowledge, but it also confirms their expertise, proves that they have applied what they know about Mendix in their day-to-day job and shows that others trust their knowledge.

Find Out More
Drag