Configure Git in Mage

By using the Git integration through Mage, Mage will automatically set your local repo as a safe directory (i.e. git config --global --add <local repo path>)

(Optional) One-way sync

Git sync is a separate Git feature that allows you to tie your local project to a remote repo. 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.

Enabling Git sync limits Git to a unidirectional sync. This means that changes made to your local repo will be overwritten by the remote repo. To sync both ways, leave Git sync disabled.

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, navigate to the settings page after you’ve configured your Git settings and tick the Git Sync box.

Git settings as environment variables

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_TYPEAuthentication type, options
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🚫
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🚫