Merge strategies for modules ("Subtree Merge", "Rebase" and "Squash")

When you are adding or editing a module, you have a number of options, that determine, how the Git history from the module is integrated into the parent repository.

All these options only affect the way the Git history is represented in the parent repository. The actual files, imported from the modules, and the Git history of the modules are always the same.

Merge Strategy

This option determines, whether the commit-graph from the module is merged into the parent graph (“merge”), or placed on top of it (“inline”). The difference is similar to that of “git merge” and “git rebase”.

Subtree Merge

Commits from the module tree are merged into the parent tree, like an external branch. This is the only option that preserves the original hashes of the commits imported from the module repository.

merge

Rebase

Commits from the module tree are included in the parent tree on the top of the existing commits. These are technically new commits, with new hashes.

inline

Squash Commits

You may “squash” the commit history from the module down to one last commit instead of including it in the parent graph completely. This will create a new commit with new hashes.

However, you can still choose, whether to merge it in a subtree or to include it in the main branch on the top of existing commits.

merge squash inline squash

Once

Adding a module adds just one commit to the parent graph, which contains the most recent state of the module repository. After the module is added, all future commits to the module will be added to the parent graph one by one.

Always

Each time there’re new commits to the module repository, only one commit is added to the parent graph, containing the most recent state of the module repository.

Never

All commits to the module are added to the parent graph one by one.

“Squash Once” and “Squash Always” will render the same result in most cases, because X-Modules app is fetching updates from the module repository every minute, and it’s unlikely that more than one new commit appears there between polls.

However, if a longer polling interval is set, or many people are committing to the module repository, it’s possible, that X-Modules fetches several new commits with one poll. In such a case, if the “Squash Once” option is selected, all these commits will be applied to the parent graph separately.

You can use any combination of Commits options and Squash options. You can also change these options on the existing X-module.