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.
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-gitInitialize multiple repositories (demo):
# Run in a new folder
$ mgit init -g https://github.com/baidu/m-git.gitTypical commands:
$ mgit -l # List all repositories managed by MGit
$ mgit branch --compact # Show branches across repositories
$ mgit status # Show ahead/behind status of each repositoryFuture 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.
Baidu App Technology
Official Baidu App Tech Account
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.