A lightweight tool for multi-platform Git repository migration, supporting selective transfer of branches and tags between different code hosting platforms.
- Cross-Platform Repository Migration: Seamlessly migrate repositories between different Git code hosting platforms
- Selective Migration: Support for migrating only specific branches and tags
- Release Management: Upload, download, create, and sync releases and attachments
- Bulk Operations: Support for batch repository synchronization at the organization or user level
- Multi-Platform Support: Compatible with GitHub, Gitee, Gitea, and cnb.cool
- Ensure you have Go 1.23+ installed
- Clone the repository and compile
git clone https://github.com/chihqiang/mpgrm.git
cd mpgrm && make build
The compiled executable will be in the project root directory
Copy the environment variable example file
cp .env.example .env
Edit the .env file and add the corresponding authentication information based on your platform
# CNB platform username (CNB does not have personal repositories; only organizations exist.
# This value is used as the "personal repository" identifier)
CNB_USERNAME="cnb"
# CNB platform access token
CNB_TOKEN="token_cnb_abcdef123456"
# Gitea platform username
GITEA_USERNAME="gitea"
# Gitea platform access token
GITEA_TOKEN="a1b2c3d4e5f6g7h8i9j0klmnopqrstuvwx"
# Gitee platform username
GITEE_USERNAME="gitee"
# Gitee platform access token
GITEE_TOKEN="z9y8x7w6v5u4t3s2r1q0ponmlkjihgfedcba"
# GitHub username
GITHUB_USERNAME="github"
# GitHub personal access token
GITHUB_TOKEN="ghp_FAKE1234567890abcdefABCDEFabcdef"
Manage repository credentials with ease and push anytime
# Basic usage
# Specify the repository URL directly via the command line.
# The default behavior (whether to read from environment variables) is controlled by --use-env.
mpgrm credential show --repo https://github.com/username/source-repo.git
# Specify the repository URL and explicitly disable reading from environment variables.
# --use-env=false means the command will only use the URL provided via --repo.
mpgrm credential show --use-env=false --repo https://github.com/username/source-repo.git
Push specified branches and tags from source repository to target repository
# Basic usage
mpgrm push --repo https://github.com/username/source-repo.git --target-repo https://gitee.com/username/target-repo.git
# Selective push of specific branches and tags
mpgrm push --repo https://github.com/username/source-repo.git --target-repo https://gitee.com/username/target-repo.git --branches main,develop --tags v1.0.0,v1.1.0
# Specify workspace directory
mpgrm push --repo https://github.com/username/source-repo.git --target-repo https://gitee.com/username/target-repo.git --workspace /path/to/workspace
mpgrm releases upload --repo https://github.com/username/repo.git --tags v1.0.0 --files path/to/file1.zip,path/to/file2.tar.gz
mpgrm releases download --repo https://github.com/username/repo.git --tags v1.0.0,v1.1.0
mpgrm releases create --repo https://github.com/username/repo.git
mpgrm releases sync --repo https://github.com/username/source-repo.git --target-repo https://gitee.com/username/target-repo.git --tags v1.0.0,v1.1.0
# List all repositories of an organization
mpgrm repo list --repo https://github.com/organization/
# List all repositories of a user
mpgrm repo list --repo https://github.com
# List and clone all repositories of an organization
mpgrm repo clone --repo https://github.com/<organization>/
# List and clone all repositories of a user
mpgrm repo clone --repo https://github.com/<username>
# Sync all repositories of an organization
mpgrm repo sync --repo https://github.com/organization/ --target-repo https://gitee.com/organization/
# Sync all repositories of a user
mpgrm repo sync --repo https://github.com --target-repo https://gitee.com
CloneURL determines whether it points to an organization or a repository based on the trailing character.
- Indicates a organization path.
- The repository name should be appended to generate a full repository URL.
- Currently, URLs without a trailing
/
(e.g.,https://github.com/org
) are NOT supported. - Examples:
https://github.com/org/ -> org
https://cnb.cool/org1/ -> org1
https://cnb.cool/org1/child1/ -> org1/child1
https://cnb.cool/org1/child1/child2/ -> org1/child1/child2
-
URLs that point to the root of a domain or user homepage.
-
Usually just for reference; no repository is implied.
-
Examples:
https://github.com/
https://github.com
https://cnb.cool
https://cnb.cool/
https://github.com/org/repo.git
https://cnb.cool/org1/child1
β οΈ Note:
The trailing/
is the key to distinguish between organization URLs and repository URLs.
Organization URLs require appending a repository name, whereas repository URLs are already complete.
- Fork this repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details
If you have any questions or suggestions, please feel free to submit issues or contact the project maintainers.