$ git remote add REMOTE_NAME REMOTE_URL
Verify that the new remote has been added by running git remote -v
and seeing your REMOTE_NAME
in the list.
# Pull the latest changes from the BRANCH_NAME of the REMOTE_NAME:
$ git fetch <REMOTE_NAME>/<BRANCH_NAME>
# For example: git fetch chris/master
Once the remote is fetched, you can rebase your branches upon that remote:
$ git checkout <MY_BRANCH>
$ git rebase <REMOTE_NAME>/<BRANCH_NAME>
# For example: git rebase chris/master
This command will add the commits you miss from
chris/master
into yourMY_BRANCH
branch.
To push changes into a different remote use this command:
$ git push <REMOTE_NAME> HEAD:<BRANCH_NAME>
# For example: git push chris HEAD:master
This pushes your current branch into chris/master
.
Be careful when pushing to remotes you don't own. Always ask the owner for the remote before doing so.