Configure Your Repository To Use The SSH Protocol

The URL you use for a repository depends on which protocol you are using, HTTPS and SSH. The Bitbucket repository Overview page has a quick way for you to see the one for your bb101repo repo. On the repository's Overview page look for the Clone this repository line.

Experiment for a moment, click back and forth between the SSH and the HTTPS protocol links to see how the URLs differ. The table below shows the format for each DVCS based on protocol.

SSH URL format

HTTPS URL format

Mercurial ssh://hg@bitbucket.org/<code><em>accountname</em>/reponame/

https://<em>accountname</em>@bitbucket.org/<em>accountname</em>/<em>reponame</em>

Git

git@bitbucket.org<em>:accountname</em>/<em>reponame</em>.git

or

ssh://git@bitbucket.org<em>/accountname</em>/<em>reponame</em>.git

https://<em>accountname</em>@bitbucket.org/<em>accountname</em>/<em>reponame</em>.git

In the SSH format, the accountname appears after git@bitbucket.org or hg@bitbucket.org. In HTTPS format, the accountname beforegit@bitbucket.org or hg@bitbucket.org.

Go to terminal on your local system and navigate to your bb101repo-practice repository. Then, do the following:

  1. View your current repository configuration.
    You should see something similar to the following:
    manthony@MANTHONY-PC ~ 
    $ cat .git/config
    [core]
      repositoryformatversion = 0
      filemode = true
      bare = false
      logallrefupdates = true
      ignorecase = true
    [remote "origin"]
      fetch = +refs/heads/*:refs/remotes/origin/*
      url = https://newuserme@bitbucket.org/newuserme/bb101repo.git
    [branch "master"]
      remote = origin
      merge = refs/heads/master
                                    
    

    As you can see, the url is using the HTTPS protocol. There are a number of ways to change this value, the easiest way is just to edit the repository's configuration file.

  2. Edit the ~/repos/bb101repo-practice/.git/config file with your favorite editor.
  3. Change the url value to use the SSH format for that repository.
    When you are done the origin section should contain something similar to the following:
    [remote "origin"]
      fetch = +refs/heads/*:refs/remotes/origin/*
      url = git@bitbucket.org:newuserme/bb101repo.git
                            
    
  4. Save your edits and close the file.