Most notes are on other pages
Click here to see the other notes on git.
Moving a repository remote origin from https to ssh
First we check the current remote origin. There are two ways:
$ git config --get remote.origin.url
https://gitlab.com/example_owner/example_repo.git
$ git remote get-url --all origin
https://gitlab.com/example_owner/example_repo.git
Find out the SSH path to your repo. It should be listed somewhere in the user interface of the git platform you use.
For GitLab and GitHub the SSH repo address pattern is different that it is for AWS.
For AWS it looks like this: ssh://git-codecommit.my-region.amazonaws.com/v1/repos/my-repo.
For GitLab and GitHub it looks like this: git@gitlab.com:example_owner/example_repo.git.
Now we set the local repository to use SSH. We have to add the SSH version first and then delete the HTTPS version; git won't allow it the other way around.
$ git remote set-url --add origin git@gitlab.com:example_owner/example_repo.git
$ git remote set-url --delete origin https://gitlab.com/example_owner/example_repo.git