Here are some common commands used in the terminal
Adding remote repo
Add a remote repo named <remote-repo> that points to the url <remote-url>
$ git remote add <remote-repo> <remote-url>
Push to Multiple Remotes
Suppose we have a repo with a remote.
$ git remote -v
origin <remote-1-url> (fetch)
origin <remote-1-url> (push)
If we want to add a second remote where we push our changes, we can do
$ git remote set-url --add --push origin <remote-1-url>
$ git remote set-url --add --push origin <remote-2-url>
Then, when it is time to push changes we do
$ git push --set-upstream origin main
Starting with a new local repo, here are the full steps:
# initialize git repo
$ git init
# add all untracked files
$ git add .
# first commit
$ git commit -m "initial commit"
# add remote repo
$ git remote add origin <remote-1-url>
# add first push url
$ git remote set-url --add --push origin <remote-1-url>
# add second push url
$ git remote set-url --add --push origin <remote-2-url>
# push to remote repo
$ git push --set-upstream origin main