- It's something else to install.
- You have to either
- Manually add the key(s) to Pageant each time you need to access your repo or
- Configure Pagent to load the keys on windows startup, which means being prompted for your passphrase for each key, even if you don't need them. A nuisance when you end up with multiple repos.
- The latest version of Putty conforms to a different standard for SSH keys, so you have to convert them to use them.
With this, I can have multiple keys, and only have the relevant one loaded when I actually need it. I have two BitBucket accounts (one for work and one personal) as well as a personal GitHub account. Let's break the above down.
Host: This is our alias. We actually change our repo URL's domain to match this. So for example, if I wanted to clone the repo firstname.lastname@example.org:me/repo.git which is in my work account, I would have to change the URL and run the following command:
- git clone email@example.com:me/repo.git
Note that we've changed the URL to include "work." Everything that sits in the Host block is the config for that domain alias. If you already have a repo cloned and you need to change the URL, run "git remote set-url."
HostName: This is where the alias URL maps to. The actual domain.
IdentityFile: The path to the private key for your chosen account. i.e. without the .pub extension.
AddKeysToAgent: The magic bit. When set to "yes" it will dynamically load the key for your Host alias when its domain is called.
For extra info on the config, check out the online docs, but that's it for me.
Let's change it to this:
Visual Studio Code
There is a way to streamline this though. I simply created a .sh file with just the word "code" in it. I then created a windows shortcut to run that file using Git for Windows. I made it prettier by adding the VS Code icon to the shortcut and used that for kicking Code off. It will even dynamically prompt you when access to a repo is needed.
The only downside being that launching Code via the context menus doesn't do it. Not perfect but close to it.
Who would have thought accessing GIT could warrant three posts, but this was part of my educational journey and was more about understanding than simply following a set of prescribed steps.
I hope this helps someone else. Let me know. Adios.
Part 1: HTTPS
Part 2: SSH