Git integration
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 safe.directory <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.
Setting | Variable | Description | Required |
---|---|---|---|
Git settings | GIT_REPO_LINK | corresponds to Remote repo url | ✅ |
Git settings | GIT_REPO_PATH | corresponds to Local directory path | ✅ |
Git settings | GIT_USERNAME | corresponds to Username | ✅ |
Git settings | GIT_EMAIL | corresponds to Email | ✅ |
Git settings | GIT_AUTH_TYPE | Authentication type, options | ✅ |
Git sync settings | GIT_BRANCH | corresponds to Branch name | 🚫 |
Git sync settings | GIT_SYNC_ON_PIPELINE_RUN | corresponds to Sync before each trigger run , options | 🚫 |
Git sync settings | GIT_SYNC_ON_START | corresponds to Sync on server start up , options | 🚫 |
Git sync settings | GIT_SYNC_ON_EXECUTOR_START | If set to “1”, Mage will attempt to run a git sync every time an executor is started, options | 🚫 |
Authentication environment variables | GIT_SSH_PUBLIC_KEY | SSH public key encoded in base64, used for ssh auth type | 🚫 |
Authentication environment variables | GIT_SSH_PRIVATE_KEY | SSH private key encoded in base64, used for ssh auth type | 🚫 |
Authentication environment variables | GIT_ACCESS_TOKEN | Git access token, used for https auth type | 🚫 |