Git sync is a Git feature that allows you to tie your local project to a remote repo. When Git sync is enabled, you will only be able to pull in changes from the remote repository. Git sync is particularly useful for deployment— for example if you’d like a hosted Mage instance to stay up-to-date with a repo.

Running a Git sync will overwrite all local changes and replace them with the code in the specified remote branch. Git syncs can be run either from the Git settings page, or before every trigger run if you selected the Sync before each trigger run field.

To enable Git Sync, first configure Git in Mage, then navigate to the settings page and tick the Git Sync box.

Syncing git submodules

Repositories synced through Mage will only update 1 level of submodules. If your submodule contains other submodules, you will need to manually update them or reformat your submodules.

If your repo contains git submodules, you can enable syncing for them by ticking the Include submodules box. Mage will use the same credentials that are provided for the main repository to update the submodules.

Git sync settings as environment variables

For Mage versions >= 0.9.51

Mage will prioritize git settings from environment variables when they are set. If you want to be able to change git settings from the UI, you will need to set the GIT_OVERWRITE_WITH_PROJECT_SETTINGS environment variable to 1. Otherwise, edits to the git settings from the UI will not be applied.

You can choose to pass in Git settings as environment variables. Mage will read from these environment variables to configure your Git repo.

Git settingsGIT_REPO_LINKCorresponds to Remote repo url
Git settingsGIT_REPO_PATHCorresponds to Local directory path
Git settingsGIT_USERNAMECorresponds to Username
Git settingsGIT_EMAILCorresponds to Email
Git settingsGIT_AUTH_TYPEThe method of authentication. See enum values here
Git sync settingsGIT_BRANCHCorresponds to Branch name🚫
Git sync settingsGIT_SYNC_ON_PIPELINE_RUNCorresponds to Sync before each trigger run, options🚫
Git sync settingsGIT_SYNC_ON_STARTCorresponds to Sync on server start up, options🚫
Git sync settingsGIT_SYNC_ON_EXECUTOR_STARTIf set to “1”, Mage will attempt to run a git sync every time an executor is started, options🚫
Git sync settingsGIT_SYNC_SUBMODULESCorresponds to Include submodules, options🚫
Authentication environment variablesGIT_SSH_PUBLIC_KEYSSH public key encoded in base64, used for ssh auth type🚫
Authentication environment variablesGIT_SSH_PRIVATE_KEYSSH private key encoded in base64, used for ssh auth type🚫
Authentication environment variablesGIT_ACCESS_TOKENGit access token, used for https auth type🚫
Global git settingsGIT_ENABLE_GIT_INTEGRATIONForce git integration module to show in the UI. Primarily useful when the version control app does not work for your repository.🚫
Global git settingsGIT_OVERWRITE_WITH_PROJECT_SETTINGSAllow users to overwrite git settings set by environment variables through the Git Settings page in the UI.🚫