Git tools that enable easy bidirectional sync between multiple repositories
mgt
has several features that make it easy to collaborate with
projects outside of your repository. It works by rewriting
your git history onto a temporary branch in a way such that the branch
can be easily merged into another repository.
Some features that mgt
provides are:
- splitting your private repository into subrepositories that only contain files/folders that you want to share publically
- bidirectional sync between repositories via transient branches that are formatted to be rebased
- checking updates of multiple subrepositories
- filtering out specific text/commits before sharing publically (TODO)
The following is one of the simplest uses of mgt
. For more interesting use cases, see the examples here
The simplest usage of mgt
is to take an entire remote repository and split-in-as
into a subdirectory of your local repository. If you are in a local git repository, you can run:
mgt split-in-as https://github.com/nikita-skobov/monorepo-git-tools --as lib/mgt/ --rebase
This will:
- create a new, temporary branch (named
monorepo-git-tools
) - fetch the remote repository (
https://github.com/nikita-skobov/monorepo-git-tools
) into that branch - rewrite the history of this new branch such that the entire contents exist within
lib/mgt/
- the
--rebase
flag tellsmgt
to then rebase that new branch onto whatever branch you started from
After those steps, you will be on the monorepo-git-tools
branch, and you can merge it however you want back into your starting branch.
mgt
knows how to rewrite your history based on files that contain information on how to map between local and remote repositories.
These files are called repo_file
s, and some common things that would
go in a repo_file
are:
- including files/folders
- renaming files/folders
- excluding files/folders
- specifying repository URL(s) to use as the destination
When you run mgt
, you typically provide a path to the repo_file
, eg: mgt split-out my_repo_file.txt
These commands are just "porcelain" commands built on top of the real "plumbing" capabilities of git-filter-repo.
You must have git-filter-repo
available on your path prior to using the tools in this repository.
The full command line usage documentation can be found here
You will need rust installed
git clone https://github.com/nikita-skobov/monorepo-git-tools
cd monorepo-git-tools
cargo build --release
chmod +x ./target/release/mgt
cp ./target/release/mgt /usr/bin/mgt
This project builds and tests every release on GitHub
To get the latest binary, go to the release page and download the zip file that is appropriate for your machine.
To install it, simply extract the zip, and copy the executable to a directory that is on your system's path.