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”.
Download Git X-Modules CLI from TMateSoft website.
Depending on your OS - unpack
If you do not have Java runtime installed on your computer - also download and install Java.
If necessary, add
gx/binto your PATH environmental variable.
Navigate to your bare git repository and run
$ gx add-module [OPTIONS] MODULE_REPO MODULE_PATH
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
You may also want to use some options.
Set the path to the Git repository you’re adding modules to
Default: current directory or
Specify branches to sync
Create an X-Module, but do not sync files and commits immediately.
To apply changes, run
pushto 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.
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.
To pull updates from the external repository, run
$ gx sync --git-dir=PARENT_REPO
PARENT_REPOis 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
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.