Git Multiple Remote Repository Configuration

This article introduces Git multiple remote repository configuration, including its advantages, implementation details, and relevant resources. These steps can help improve efficiency when configuring multiple remote repositories in Git.

Nov 27, 2017 · 1 min read · 130 Words · -Views -Comments · Programming
Git 🇨🇳 阅读中文版
Read with AI

Choose an AI assistant

ChatGPT Open in a new tab with the article link and prompt
Claude Copy the prompt, then open Claude

Open Claude
Trouble reading the article?

If the prompt is missing, copy the full prompt below into your AI assistant. If the AI cannot read the article, paste the visible passage you want to discuss and add your question.

In actual development, sometimes you may encounter situations where Git projects need to be hosted on multiple remote addresses. Fortunately, Git supports multiple upstreams, so the operation is quite simple.

Example

For example, we have GitHub and Gitee (formerly known as OSChina) repository addresses

# Add GitHub
$ git remote add github https://github.com/alanhe421/NiceFish.git

# Add Gitee
$ git remote add oschina https://gitee.com/mumu-osc/NiceFish.git

# Push to GitHub
git push github master

# Push to multiple repositories
git push --all 

Syntax Explanation

For detailed information, please refer to the official manual: Link

# name is the remote name, url is the address
$ git remote add  <name> <url>

# --all, push all branches, repository is the repository address or remote name, refspec is the branch name
$ git push [--all] [<repository> [<refspec>…​]]
Authors
Developer, digital product enthusiast, tinkerer, sharer, open source lover