Change the URI (URL) for a remote Git repository

A figurine of an oktokat in the center, in the background a laptop with the main page of the GitHub open.

You can access a Git repository using either SSH or HTTPS and can change to either one depending on your use case.

To check which repository your project is connected to, you can use the following command:

$ git remote -v

To change your project's repository, use the following command:

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

Replace <remote_name> with the name of the remote repository that you want to modify (for example, "origin"), and replace <new_url> with the new URL for the remote repository.

For example:

$ git remote set-url origin https://github.com/marcomaranao/marco.git
$ git remote set-url origin git@github.com:marcomaranao/marco.git

 

Add new comment

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.