Commit ef1fcfd2 authored by Sadman Kazi's avatar Sadman Kazi 🎸

Add pushing to multiple remotes

parent b04a594c
......@@ -25,6 +25,7 @@ Table of Contents:
### Git
* [Configuring using `git config`](git/configuring-using-git-config.md)
* [Pushing to multiple remote repos](git/pushing-to-multiple-remote-repos.md)
* [Useful aliases: `push --force-with-lease`](git/useful-aliases-push-force-with-lease.md)
### Linux
......
Pushing to multiple remote repos
================================
Multiple remote URLs can be set to the same remote using the `remote set-url REMOTE_NAME --STREAM --add REMOTE_URL`
command. For example, say we want to assign two different URLs `git@github.com:sadmansk/til.git` (as a `push`
mirror) and `git@git.sadmansk.com:sadmansk/til.git` (original repo) to the same remote `origin`, we can issue
the following commands:
```
$ git remote add origin git@git.sadmansk.com:sadmansk/til.git
$ git remote set-url origin --push --add git@github.com:sadmansk/til.git
$ git remote set-url origin --push --add git@git.sadmansk.com:sadmansk/til.git
```
> Leaving out `--push` will make the remote `pull`-able, which might not be safe.
We can check the current list of URLs attached to all the remotes:
```
$ git remote -v
origin git@git.sadmansk.com:sadmansk/til.git (fetch)
origin git@github.com:sadmansk/til.git (push)
origin git@git.sadmansk.com:sadmansk/til.git (push)
```
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment