mirror of
https://codeberg.org/Codeberg/Documentation.git
synced 2026-08-15 14:53:29 -07:00
add instructions to switch from https to ssh in ssh-key.md
This commit is contained in:
parent
b0b19675f2
commit
7fba31ab1d
1 changed files with 45 additions and 0 deletions
|
|
@ -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 <remote-name> <remote-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.
|
||||
|
|
|
|||
Loading…
Reference in a new issue