Operations 5 min read

How to Set Up and Push to Two Remote Git Repositories (GitHub and Gitee)

This guide explains how to create identical repositories on GitHub and Gitee, clone them locally, replace the default remote, add both remotes, and push code to each, while also covering common authentication and push‑rejection issues.

Wukong Talks Architecture
Wukong Talks Architecture
Wukong Talks Architecture
How to Set Up and Push to Two Remote Git Repositories (GitHub and Gitee)

This article demonstrates how to manage a project with two remote Git repositories—GitHub and Gitee—so that code can be synchronized to both platforms.

1. Create two remote repositories on GitHub and Gitee, optionally importing one from the other.

2. Clone the repository to your local machine:

git clone [email protected]:Jackson0714/PassJava-Learning.git

3. Remove the existing remote named origin :

git remote rm origin

4. Add the two remotes with distinct names:

git remote add github [email protected]:Jackson0714/PassJava-Learning.git
git remote add gitee [email protected]:jayh2018/PassJava-Learning.git

Note that the remote names are github and gitee , not origin .

5. Verify the configuration using:

$ git remote -v

which should list both github and gitee for fetch and push.

6. Push to both remotes :

git push github master
git push gitee master

You can also use visual tools such as TortoiseGit to push to all configured repositories.

7. Common issues :

If you see a host authenticity warning, answer yes to continue.

If the push is rejected because the remote has newer commits, either pull the changes first or force‑push with git push gitee master -f .

Following these steps ensures that your local repository stays in sync with both GitHub and Gitee, providing redundancy and broader accessibility.

DevOpsgitTutorialGitHubGiteePushRemote Repository
Wukong Talks Architecture
Written by

Wukong Talks Architecture

Explaining distributed systems and architecture through stories. Author of the "JVM Performance Tuning in Practice" column, open-source author of "Spring Cloud in Practice PassJava", and independently developed a PMP practice quiz mini-program.

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.