diff --git a/content/security/ssh-key.md b/content/security/ssh-key.md index d5eb67c..9b8c889 100644 --- a/content/security/ssh-key.md +++ b/content/security/ssh-key.md @@ -116,5 +116,50 @@ $ eval $(ssh-agent) $ ssh-add # enter your passphrase once, then it is cached. ``` +## Changing your repository from HTTPS to SSH + +1. Go to the directory where your repository is located: + + ``` + cd /path/to/repository + ``` +2. Look at the existing remotes with `git remote` : + + ``` + git remote -v + ``` + + It will look similar to this: + + ``` + origin https://codeberg.org/knut/foobar.git (fetch) + origin https://codeberg.org/knut/foobar.git (push) + ``` + + You might be using a different name than `origin` for your repository. If you do, remember to use that different name in the following steps. +3. Run `git remote set-url` command followed by the remote name and the remote’s URL: + + ``` + git remote set-url + ``` + + For example, to change the URL of `origin` to `git@codeberg.org:knut/foobar.git` you would type: + + ``` + git remote set-url origin git@codeberg.org:knut/foobar.git + ``` +4. Verify that your change was successful: + + ``` + git remote -v + ``` + + The output should look like this: + + ``` + origin ssh://git@codeberg.org:knut/foobar.git (fetch) + origin ssh://git@codeberg.org:knut/foobar.git (push) + ``` + > **Attribution** > This guide is derived from [GitHub Docs](https://docs.github.com), used under CC-BY 4.0.