Site icon Narayana Tutorial

Git Origin Remote SSH URL change

Git Self Signed Certificate

Git Self Signed Certificate

Git Origin Remote SSH URL change

In order to change the Remote SSH URL of a Git, we have to use the set-url command and specify the name of the remote as well as the new remote URL to be changed.

When we do git clone the project, automatically remote SSH URL repository is the default origin for Push and Fetch. Now if we want to change the remote SSH URL point to another repository then we have to update the remote URL like as follows.

Existing Remote SSH URL:

$ git clone git@github.narayanatutorial/JavaMail.git
$ git remote -v
origin  git@github.narayanatutorial/JavaMail.git (fetch)
origin  git@github.narayanatutorial/JavaMail.git (push)

Here remote SSH URL is git@github.narayanatutorial/JavaMail.git

If we want to change the remote SSH URL, we need to use the set-url command.

Set new Remote URL:

Syntax

 $ git remote set-url <remote_name> <remote_ssh_url>

Example:

$ git remote set-url origin git@github.narayanatutorial/JavaMail_New.git
$ git remote -v
origin git@github.narayanatutorial/JavaMail_New.git (fetch)
origin git@github.narayanatutorial/JavaMail_New.git (push)

Now we can push the project into the new repository JavaMail_New.git