How to update the URL for Git repositories

  1. From a terminal, navigate to the repository. $ cd ~/<path_to_repo>
  2. Run git remote -v to see the current remote URL.

  3. $ git remote -v
  4. origin https://[email protected]/tutorials/tutorials.git.bitbucket.org.git (fetch)
  5. origin https://[email protected]/tutorials/tutorials.git.bitbucket.org.git (push)
  6. Update the remote URL with git remote set-url using the current and new remote URLs.
  7. $ git remote set-url origin [email protected]:tutorials/tutorials.git

If you update your URL from HTTPS to SSH, next time you push or pull from your repository, the terminal responds that it is adding the Bitbucket host to the list of known hosts. You also won't have to enter a password.

Useful Tags :