Accelerating Git Clone Speed Using Gitee Mirror and Submodule Optimization
This guide explains how to boost Git repository download speeds in China by mirroring projects to Gitee, using fork and clone operations, and optimizing submodule handling to achieve transfer rates of 1–2 MB/s instead of the typical 20 KB/s.
Downloading code from GitHub in China often tops out at about 20 KB/s, which is acceptable for small projects but painfully slow for larger repositories with many submodules.
This article presents a practical method to increase download speed to roughly 1–2 MB/s by leveraging the Gitee (码云) platform as a mirror for GitHub repositories.
1. Use Gitee’s repository mirroring
The process requires a GitHub account and a Gitee account. First, fork the desired GitHub project to your own GitHub account ( fork ). Then, log into Gitee, click the "Add Project" (+) button, choose "Migrate GitHub project", link your GitHub account, and select the repository to migrate. Finally, clone the repository from Gitee using the Gitee URL ( clone ), which provides download speeds measured in MB/s.
After migration, you no longer need to keep a night‑long clone running.
Step 1: Create a new repository on Gitee
(Image illustrating repository creation)
Step 2: Example with a GitHub repository
https://github.com/PX4/Firmware.git (illustrated with screenshots)
Step 3: Configure the remote URL
(Image showing remote URL setup)
Step 4: Complete the migration
(Image showing final steps)
2. Speed up submodule downloads
When a project contains submodules, a standard clone does not automatically fetch them because they reside at separate URLs. After cloning the main project, run:
git submodule update --init --recursive
This command pulls the submodule code from its original locations, which may still be on GitHub and thus limited to 20 KB/s. To accelerate this, apply the same mirroring technique to each submodule:
Identify the submodule URLs used by the project.
Fork each submodule repository to your GitHub account, then migrate it to Gitee.
Replace the original submodule URLs in the main project with the new Gitee URLs.
Run git submodule update --init --recursive again to fetch the submodules from Gitee at higher speeds.
These steps significantly reduce the time required to download large projects with many dependencies.
Appendix
References for modifying submodule URLs:
https://blog.csdn.net/wangjia55/article/details/24400501
https://www.jianshu.com/p/c81e2bd377ad
https://blog.csdn.net/qq_22630169/article/details/74236535
Selected Java Interview Questions
A professional Java tech channel sharing common knowledge to help developers fill gaps. Follow us!
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.