Operations 5 min read

MGit: A Multi‑Repository Management Tool for Efficient Git Operations

MGit is Baidu’s open‑source, Ruby‑based multi‑repository management tool that streamlines batch Git operations across hundreds of component repositories, reduces error risk, offers readable output and simple commands, and is already used in dozens of Baidu products while encouraging community contributions.

Baidu App Technology
Baidu App Technology
Baidu App Technology
MGit: A Multi‑Repository Management Tool for Efficient Git Operations

MGit is a Git‑based multi‑repository management tool that safely and efficiently manages multiple Git repositories. It is designed for projects that involve interrelated development across many repositories, providing batch version management, improving Git operation efficiency, and reducing the risk of errors caused by executing Git commands one by one.

In the evolution of Baidu APP componentization, each component was given a clear physical boundary to facilitate fine‑grained permission control and output. The client codebase was split into more than 200 components and repositories. To lower the operational cost of handling many repositories, Baidu developed MGit, modeled after Google’s Repo, with a lower learning curve, more readable output, and safer logical processing.

MGit currently serves a range of Baidu product lines, including Baidu APP (mobile), Baidu Netdisk, Baidu Tieba, Haokan Video, and Quanmin Short Video, totaling 24 product lines by the end of 2020.

Architecture Design

Core concept: operate multiple repositories based on a configuration table.

Command execution cycle:

Command parsing – determines the command type and separates native Git parameters from custom parameters.

Command execution – invokes the appropriate script and operates the specified repositories based on the parameters.

Installation and Usage

Environment requirements:

OS: macOS, Ubuntu (Windows not supported)

Ruby version: >= 2.3.7

Installation:

gem install m-git

Initialize multiple repositories (demo):

# Run in a new folder
$ mgit init -g https://github.com/baidu/m-git.git

Typical commands:

$ mgit -l               # List all repositories managed by MGit
$ mgit branch --compact # Show branches across repositories
$ mgit status           # Show ahead/behind status of each repository

Future Plans

1. Feature sharing – continue to improve MGit’s multi‑repo capabilities and share technical insights via official channels.

2. Community co‑construction – build an open community, welcome developers to contribute to maintenance and upgrades.

Project open‑source addresses:

GitHub: https://github.com/baidu/m-git

Gitee: https://gitee.com/baidu/m-git

Feedback and issues can be submitted on either platform, and the team will respond promptly.

gitcommand-lineinstallationMulti-repoMGittool
Baidu App Technology
Written by

Baidu App Technology

Official Baidu App Tech Account

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.