Change Origin of a git repository

If you want to change the URL of a repository to which it points to, then this post is for you. If you try the same command:

git remote add origin http://github.com/USERNAME/OTHERREPOSITORY.git

then it is not gonna work and you will probably get error like this:

fatal: remote origin already exists.

List your existing remotes in order to get the name of the remote you want to change

git remote -v

Change your repository’s remote url with command:

git remote set-url origin https://github.com/USERNAME/OTHERREPOSITORY.git

Substitute the values of USERNAME and OTHERREPOSITORY with yours.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s