How to view and change your remote repository in GitHub?

By | August 5, 2021

In your Git repository, run the command

git remote -v

to “verify” your remote repository definition.

This should show something like

~/Code/subQuery/projects/subql-starter$ git remote -v
origin (fetch)
origin (push)

To add another “origin”, run the command

git remote add origin1<username/repo.git>

For example:

git remote add origin1

Note that you have to use a unique name. Now run remote -v again

~/Code/subQuery/projects/subql-helloworld$ git remote -v
origin (fetch)
origin (push)
origin1 (fetch)
origin1 (push)

To remove a remote, run

git remote rm origin1

Why would you want to do this?

You would want to do this if you are cloning from one repo and you want to push to another repo. Note that you need to have permission on the repo that you are pushing to so make sure the repo owner has given you (and you have accepted) the invitation.

Category: Git

Leave a Reply

Your email address will not be published. Required fields are marked *