Setup Git for using GitLab (including SSH key) - Windows 10

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
today i'll show you how to generate and configure your ssh key for gitlab if you're using windows 10 for mac os or linux the process is similar but i will link you to a different tutorial for that let's get started [Music] so i have this repository in gitlab and i'm just trying to essentially clone this repository make a copy of this repository locally on my computer and make some changes to it so one of the first things you need to do is to figure out if you already have git installed so essentially if you open any terminal and you type in something like git dash dash version and you're getting something back and not an error as in this case it means that you already have git installed however if you don't have git installed what i recommend you do is to go to git dash scm.com by the way everything that i'm talking about links or commands that i'm typing in they will be available in the video description so make sure you check that out i'll also be posting updates just in case something changes so in this case for windows what you need to do is to download from here the latest version your operating system will be already detected so i'm going directly to my downloads and clicking the installer it is actually quite a long installation process and i don't want to bore you with all the details essentially what we're going to do is we're going to leave the defaults as they are as for most users this is essentially everything that is needed so if you feel that at any point there is something that you would like to have different because you know you have the know-how in that regard feel free to make changes but if this is like your first time installing git this is like you're just getting started right now leave the defaults as they are as the installation process itself is already let's say pretty weird and pretty detailed for beginners so finally going to install okay so that's about it one of the tools that come bundled with this installation is the so called git bash so i'm gonna click here to launch kit bash this is like another terminal window that helps you interact with git let me make this a bit larger all right so now we can double check again that indeed we have git installed and you should see something like git version whatever is the latest version so going back to the repository that you are trying to work with you should be able to see this button here it's called clone so when you're cloning it you have essentially two options one of them is to clone with ssh and i'm gonna explain a bit what that is and the other one is to clone with https now with any currently with https what's happening is that you will be asked for your username and password now when working with git generally with working with remote servers we don't want to work with username and password we want to work with ssh ssh is a way to authenticate without exposing your username and password ssh stands for secure shell and is a cryptographic protocol based on the concept of public private keys we're using ssh with git because it is much easier than typing your username and password all the time it is also a bit more secure so what i'm going to do next is simply copy this url go back to git bash and write for example the command git clone i'm going to paste that url now in this case it will try to clone it by using ssh but because it cannot find any keys it will try still by username and password i just wanted to show you how this looks like so this essentially is detecting a new host and that's totally fine it will not ask you this again if you type here yes and it will say here permission denied public key sometimes it may even try to do it by using https it depends from case to case but essentially we don't have the permission to access this repository because it's a private repository and we haven't configured or provided any credentials so the next step would be to generate a public and a private key so the tool that we're going to use is called ssh keygen and this has been already installed as you install git in the installation process if you're getting any errors running these commands try to restart a computer once sometimes in windows this may take a bit until everything is properly installed sometimes just restarting the terminal that can also help so i'm running this command and this is essentially what's happening in order to generate this public private rsa error says the encryption standard that's being used by default it will be saved in your user folder mine is valentine and in this folder called dot ssh sometimes you may not even see it if you're using explorer but it is there and it's good to leave it there as a default path so i'm simply going to click enter i don't want to change that the next step is you're going to be asked for a passphrase so your private key can be additionally secured with a password essentially now unfortunately setting this passphrase when using windows is really a pain and for simplicity reasons i'm not gonna set the passphrase but essentially to understand the security risk if somebody gets access to the computer if your files are not encrypted and they can read this private key which will be stored here in id underscore air say they can get access to your repositories without being asked for any password or anything like this but as i mentioned under windows getting this to run without you being bugged to enter a passphrase every time you do something is i would say way too complicated so we are just gonna skip it for now so i'm not gonna enter any passphrase and this is gonna be randomly generated for you and this is cryptographic secret that is there so this is essentially impossible to guess if you don't have the private key so what has happened essentially is in this folder that you see here there are two files that have been generated one of them is this private key and the other one is a public key now you can notice here that inside gitlab if you don't already see this message all the time like add your ssh key at your ssh key you can click it here to add your ssh key in case you don't see it you can go to your profile go to settings and from this menu on the left hand side you should be able to see ssh keys and by default you will not have any of them installed so we are gonna copy our public key we always share our public key with others with servers with gitlab we never share our private key as a name is telling you a private key should be private to you otherwise if you do that and not only it will not work but you're also exposing yourself so i'm gonna use a command it's called cat this will give us the contents of a specific file so i'm gonna simply go ahead copy the path here and i was mentioning there are essentially two files inside there so one of them is this id rsa this is the private key and the other one is id rsa.pub this is the public key this is what we're trying to add to gitlab you can use a text editor to get to this file but because we already have the terminal here open we're going to use that so what i'm going to do is simply select the entire text that you see here click on copy and here inside gitlab i'm going to paste it i can even write here this is for windows 10 or whenever it doesn't have an expiration date so we can simply click here on add key and this will be then saved to know exactly when you created it of course later on if for some reason your ssh key has been compromised you can go back here to your profile and click on this trash icon and you can delete it without changing your gitlab username and password you know just in case something doesn't work you can play around with this it's absolutely fine so now we're going back to gitlab let me clear this for you and let's try again the command that allows us to clone so git clone and we're trying this private repository and you will see here now the clone process has worked without any errors i didn't have to type in any password or anything like that so for example if you're using an ide i have here visual studio code that should work more or less the same just in case you're not familiar with git using it from the terminal that's totally understandable so you can use any ide tool and that should automatically detect get and should be able to work with your repository without absolutely any problems so what we can do here is let's see for example you can go ahead here and clone a repository let me grab the address of this repository once again clone i'm gonna get ssh now of course i'm being asked where to save it just gonna do it on the desktop right now it doesn't really matter a lot so now it's cloning this and then i can look here inside to see what does this project contain it is just a simple file it's not much so for example if i decide to do a change like add let's say here new file hello from git let's save it and here inside the version control part i can see the files that i've changed and what i've added and i can simply add a commit message and did a new file on the stage all the changes and one of the things that you will get initially is this information regarding configuring your username and emailing it that's very important otherwise your work colleagues will look at you very weirdly while you're committing with weird names or where you haven't set up your proper name and email address so the commands that you need to run are the following so you need to run here git config and specify your email so i'm going to simply use the same terminal here and you know add whatever email that you want to show up in your git commits and additionally the next command that you may want to run is also this like configuring your name typically it is your first and last name but use whatever works for you those commands will be also available in the video description for you to easy copy paste in your own configuration so now i've added this already so i shouldn't get any additional errors from here i'm gonna click here again on commit no more warnings and what i can do is i can simply push these changes so that's about it so essentially if we go back to our repository you can see here that the new file that we added is available here and we are trying to see exactly who made this commit you will see here that your name is essentially what you have configured from git so this is important for the git history that you will be able to see here i hope that everything worked as i've shown you in the tutorial and that you can now start using git and gitlab i would really appreciate if you would give this video a thumbs up and consider subscribing see you next time guys you
Info
Channel: Valentin Despa
Views: 33,765
Rating: undefined out of 5
Keywords: new gitlab ssh key for profile, gitlab tutorials for beginners, git for windows, using ssh on windows, setup git path in windows, gitlab tutorial, gitlab ce tutorial, windows 10, git installation on windows 10, how to install git on windows 10, ssh keys gitlab windows, how to create ssh key in gitlab, windows 10 ssh, gitlab for projects, windows 10 openssh, gitlab for android studio, gitlab install windows, gitlab install on windows, how to install gitlab runner on windows
Id: Vmt0V6a3ppE
Channel Id: undefined
Length: 13min 42sec (822 seconds)
Published: Wed Jan 27 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.