Git changing remote URLs

git remote set-url <name> <newurl> command changes existing remote repository URL.

For example, to switch from a github repository from HTTPS to SSH:

  1. Change the current working directory to local project.

  2. List existing remotes in order to get the name of the remote to change.

    1
    2
    3
    git remote -v
    origin https://github.com/shark-oxi/RawSec.git (fetch)
    origin https://github.com/shark-oxi/RawSec.git (push)

  3. Change remote's URL from HTTPS to SSH with the git remote set-url command.

    1
    git remote set-url origin [email protected]:shark-oxi/RawSec.git

  4. Verify that the remote URL has changed.

    1
    2
    3
    git remote -v
    origin [email protected]:shark-oxi/RawSec.git (fetch)
    origin [email protected]:shark-oxi/RawSec.git (push)

Share