Operations 9 min read

Backing Up and Synchronizing GitHub Repositories to Gitee: Manual and Automated Approaches

This guide explains why backing up GitHub projects to Gitee is important amid political interference and provides step‑by‑step instructions for migrating existing repositories, handling future code changes, and automating synchronization using scripts or GitHub Actions.

IT Services Circle
IT Services Circle
IT Services Circle
Backing Up and Synchronizing GitHub Repositories to Gitee: Manual and Automated Approaches

Recent political controversies have affected open‑source projects such as Node and React, prompting many developers to back up their GitHub repositories to an alternative platform like Gitee to protect their rights.

Existing repository sync

Gitee’s website offers a one‑click import feature. The process consists of three steps:

Click the + button and choose "Import repository from Github/Gitlab".

Authorize Gitee to access your GitHub account.

Select the tab that imports all repositories from the current page.

After the import finishes, all projects are private on Gitee, so no sensitive data is exposed.

Synchronizing future code

Solution 1: Add a remote source

Use the standard Git command to add a new remote pointing to Gitee:

git remote add <name> <url>

Then:

Add the Gitee remote to your existing GitHub repository.

Push the current changes to both origins: git push origin // push to GitHub git push gitee // push to Gitee

This method requires two push commands each time.

Solution 2: Add a push‑only source

First remove the Gitee remote added in Solution 1:

git remote rm gitee

Then add the Gitee URL as an additional push destination:

git remote set-url --add origin [email protected]:hua1995116/mmt.git

Now a single git push origin will update both GitHub and Gitee.

Solution 3: Use a script (mmt)

If your GitHub and Gitee usernames are identical, you can install the mmt CLI to automate the import:

npm i -g mmt
mmt import https://gitee.com/hua1995116/mmt-practices/raw/master/mmt-export-gitee.json
# In each repository directory
mmt run gitee

This adds the Gitee remote and pushes the code with a single command.

Solution 4: GitHub Actions

Create a workflow file .github/workflows/gitee-sync.yml that runs on every push to master and uses the Yikun/hub-mirror-action to mirror the repository to Gitee. The workflow requires three secrets in the GitHub repository:

GITEE_USER – your Gitee username.

GITEE_PRIVATE_KEY – the private key matching a Gitee SSH public key.

GITEE_TOKEN – a personal access token for creating repositories on Gitee.

After setting up the secrets, every commit to GitHub will automatically be synchronized to Gitee.

Comparison of the three main solutions

Solution 1

Solution 2

Solution 3

Advantages

1. Simple configuration

2. Full control over the source

1. Simple configuration

2. Easy push

1. Simple configuration

2. Push workflow unchanged

Disadvantages

Requires two pushes each time

Cannot control the source

GitHub Actions may be blocked

Rating

⭐️⭐️⭐️

⭐️⭐️⭐️⭐️⭐️

⭐️⭐️⭐️

In light of recent events, GitHub has stated it will continue to provide services worldwide, but some accounts have still been suspended, underscoring the importance of backing up data.

Backup your data now – you never know when tomorrow or an unexpected incident will arrive.

Thank you for reading; please share this guide with anyone who might need it.

References

https://gitee.com/help/articles/4284

Gitee SSH key management: https://gitee.com/profile/sshkeys

Generate SSH public key: https://gitee.com/help/articles/4181#article-header0

Add SSH public key to Gitee: https://gitee.com/profile/sshkeys

Gitee personal access token: https://gitee.com/profile/personal_access_tokens

GitHub’s response to the war in Ukraine: https://github.blog/2022-03-02-our-response-to-the-war-in-ukraine/

DevOpsGitGitHubBackupGiteerepo-sync
IT Services Circle
Written by

IT Services Circle

Delivering cutting-edge internet insights and practical learning resources. We're a passionate and principled IT media platform.

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.