Git X-Modules CLI Quick Start Guide

Git X-Modules syncs a directory in a Git repository with another Git repository. This is often useful to put together code, that is spread between several repositories, or to share common assets among several projects. A directory, synced with another repository, is called an “X-Module”.

  1. Download Git X-Modules CLI from TMateSoft website.

  2. Depending on your OS - unpack .zip or install .deb.
    If you do not have Java runtime installed on your computer - also download and install Java.

    If necessary, add gx/bin to your PATH environmental variable.

  3. Navigate to your bare git repository and run

    $ gx add-module [OPTIONS] MODULE_REPO MODULE_PATH
    

    Where:

  • MODULE_REPO - a URL or a path to some other bare Git repository that you would like to sync with yours

    Note: If your need to supply your credentials to access this repository, use Git Credentials Storage.

  • MODULE_PATH - a directory in your repository to become an X-Module (i.e. to be synced with MODULE_REPO)

You may also want to use some options.
  • --git-dir=PARENT_REPO
    Set the path to the Git repository you’re adding modules to
    Default: current directory or $GIT_DIR if specified

  • --ref=PARENT_REF:MODULE_REF
    Specify branches to sync
    Default: refs/heads/master:refs/heads/master

  • --no-sync
    Create an X-Module, but do not sync files and commits immediately.
    To apply changes, run gitx sync or push to this repository.
    This is useful to create several X-Modules with one commit.

    For the whole list of available options, see Git X-Modules Reference Guide.

  1. A new directory has been created in your repository tree. It contains the contents you pulled from the external repository.

    Each time you change something in this directory and push your changes to your repository, these changes will be immediately pushed to the external repository. If these changes are rejected at the external repository, the push will be rejected at your repository as well.

  2. To pull updates from the external repository, run

    $ gx sync --git-dir=PARENT_REPO
    

    Where PARENT_REPO is the repository with X-Modules you are updating.

We recommend setting it up as a scheduled task.

There are many ways to set automatic tasks, depending on your OS. In Debian Linux, the most common way is to add a line to your crontab. To do so, run

 $ crontab -e

Then in the text editor of your choice, add this line to the opened file:

 */5 * * * * gx sync --git-dir=PARENT_REPO

where PARENT_REPO is the repository with X-Modules you are updating.
Save and close.

This will run gx sync every 5 minutes. You may set any other sequence. See Crontab Reference for more detail.

For more information, read the Git X-Modules documentation.
Or, if you get stuck, feel free to ask a question at this forum!