Switching remote URLs from HTTPS to SSH

If you access the git repository via HTTPS you have to provide each time authentication data. Switching to SSH is more convenient and secure. After adding your public SSH key to the repository in GitHub (or any other) you can access the repository with SSH. To switch your local git repository:

# show current remote urls
git remote -v
# switch remote
git remote set-url origin git@github.com/user/repository.git
# check again
git remote -v

Replace user and repository and you are done. You may consider that other providers like Atlassian Stash or Bitbucket have another syntax.

# Bitbucket example with user
git remote set-url origin ssh://git@bitbucket.org:user/repository.git
# Atlassian Stash example with default ssh port
git remote set-url origin ssh://git@stashhost:7999/repository.git