git push to different remote code example

Example 1: git push to all remotes

#To push all branches to all remotes:
git remote | xargs -L1 git push --all

#Or if you want to push a specific branch to all remotes:
#Replace master with the branch you want to push.
git remote | xargs -L1 -I R git push R master

#(Bonus) To make a git alias for the command:
git config --global alias.pushall '!git remote | xargs -L1 git push --all'

Example 2: git push new repo to remote

$ git remote add origin <remote repository URL>
# Sets the new remote

# Push the changes in your local repository to GitHub.
$ git push -u origin master
# Pushes the changes in your local repository up to the remote repository you specified as the origin

Example 3: how to push code to another remote git repository

git remote rename origin upstream
git remote add origin URL_TO_GITHUB_REPO
git push origin master

Example 4: git push to different remote branch

# To remove the exist origin
git remote remove origin

# And then add new origin master URL
git remote set-url origin git://new.url.here

Follow me on GITHUB/bilalahmedkhatri

Example 5: git push to another repository

Create a new repo at github.
Clone the repo from fedorahosted to your local machine.
git remote rename origin upstream
git remote add origin URL_TO_GITHUB_REPO
git push origin master
Now you can work with it just like any other github repo. 
To pull in patches from upstream, 
simply run git pull upstream master && git push origin master.

Example 6: github push code from one repo to another

cd rhq
git push https://github.com/user/example master:master