I HIGHLY RECOMMEND FOLLOWING MY GUIDE, ‘Getting Started with Git CLI for windows (Git Bash)‘ BEFORE YOU START READING THIS PAGE!!!
- What is Git?
- What are ‘branches’?
- Getting Started
NOTE: THIS IS NOT AN IMPORTANT STEP TO WORKING WITH GIT! This is for people who don’t like having to key in their username and password when using git.
Now we want to set up SSH to be able to access our remote repository without a password. First thing’s first, there are two notable ways to go about this:
- OpenSSH (I suggest this one, yes, it uses the command-line but it’s only 3 lines of code…)
- PLink (No command-line involved, but still tricky, not worth the effort in my opinion)
If you followed my guide, Getting Started with Git CLI for windows (Git Bash), then we can simply re-use the SSH key that was generated there. To do this, simply right-click anywhere on your desktop to bring up the TortoiseGit options, from which you want to go to settings. Once there, you simply need to go to Network and change the SSH file to use ssh.exe instead of PLink. ssh.exe can usually be found in Git’s install directory under C:\Program Files\Git\usr\bin\ssh.exe.
If you did not follow my guide, Getting Started with Git CLI for windows (Git Bash) and do not want to, well… fair enough, there is another way to get SSH access without using the fancy-schmancy command-line, and here it is (I actually feel this way is MORE complicated). I feel it’s my responsibility to tell you that I hate this method so much, I would rather not even mention it, however, what if you are in some rare circumstances where the above guide on OpenSSH is not an option for you… I have no idea what this situation might be… but…. what if?
- Make sure Tortoise Git is setup to use PLink by opening the settings (see the above gif) and changing the SSH Client to use TortoisePLink which you can usually find in C:\Program Files\TortoiseGit\bin\TortoisePlink.exe.
- Open puttygen which will generate your key for you. The fastest way to do this is to hit the window key and just type ‘puttygen‘ in to the search.
- When it opens, hit the generate button and follow the on-screen instruction to move your mouse randomly to generate a random key.
- Once your key is generated, copy the result, we’ll use this later.
- Save the private key to some place that makes sense to you. For me, it makes sense to keep this in the same folder where I keep all my projects. The whole process looks like this:
- Remember that we copied that key before. It needs to be pasted to GitLab. Go to GitLab and under Profile Settings, find SSH Keys and paste yours in. Remember to name it.
- We’re not done just yet… seriously… the OpenSSH method is so much easier than this… remember the Private Key which we saved out from puttygen in step 5? Keep that in mind while we attempt to clone a project from GitLab. Browse to your project on GitLab and grab the SSH Address:
- In windows, browse to whichever folder you want to hold all your projects in, and attempt to clone by right-clicking in that folder and selecting ‘Git Clone‘.
- In the prompt that appears, if you followed step 7, you should see Tortoise has auto-pasted that address in to the URL field. Your job is enable “Load Putty” and browse to find the Private Key you saved out in step 5:
- Hit ‘OK’, your project will begin to clone, and you’ll never have to set this up again…. ever… on this machine… From now on when you Git Clone, your clone window will have this setup by default.