How to Clone a Private GitHub Repository using SSH

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello and welcome back to another lecture in this lecture i'll show you how to clone private repositories on your computer using the ssh method we will use github in this example but the same concept applies to gitlab and bitbucket to clone a private repository on your computer you will need to install git on your computer then you will create a keypair once you create the keypair you add the public key of the keypair to your version control2 and once you've done that you can clone your repository you will need a git of account and a private repository to complete this tutorial so first i'll show you how to sign up for a github account and create a private repository if you don't have one to sign up for a free git of account in google type git up in the search box then press enter under your google search results it is the one that says github.com select it and it is going to bring you to the github page to sign up for a free account click sign up and enter your email address once you enter your email click continue then create a password for your account once you've entered the password for your account click continue then enter a username for your account once you've entered your username click continue and it is asking us this question would you like to receive product updates and announcements via email if you want to type y for yes and if you don't want to type n for no in my case i'll type n for no and click continue and down here it wants you to solve this puzzle problem to verify that you are human i'll click start puzzle and the question is pick the spiral galaxy i'll select this one and it is asking the same question again i'll select this one once you pass the puzzle test click create account a launch code has been sent to the email i provided so i need to go into my email get the launch code and enter them here so i'll go into my email and this is the launch code i'm going to enter it in here it is four one four nine three zero three one once you enter the launch code it is going to bring you to this page and on this page you can personalize your account so here we have some questions we can answer or you can skip it i'm going to answer the question the first question is how many team members will be working with you i'll click just me and the next question is are you a student or teacher i'll click student and click continue on this page you can specify the specific features you are interested in using or you can just go all the way down and click continue and on this page we are going to choose our account type we have the free version and we have the git up pro we are going to use the free version so i'll scroll all the way down and click continue for free and there you go this is how you sign up for a free github account moving forward we will store all the codes for our project in the github account now that we have signed up for a free git of account to create a repository click create repository then give your repository a name we'll call this repository terraform project once you've given the repository a name we will enter a description for it once you've entered the description for your repository click private repository this means that this repository is not going to be available to the public this is also the type of repository you will use at work so in this project i want to show you how to work with private repository that way you will be familiar with it so here make sure you select private and under initialize repository with we are going to click add a readme file and we are also going to click add dot ignore once you click this add dot ignore we will select the dot ignore for terraform select this drop down then scroll down here i'm going to scroll down to the t section and look for terraform on the t section select terraform when we add dot ignore file for terraform what this means is there are some terraform files that shouldn't be committed into our repository github already knows what those files are so by adding dot ignore for terraform github will automatically ignore the teraform files that shouldn't be committed into our repository once you've added.ignore click create repository and there you go we have successfully created the repository that we will store all of our terraform projects in and i am already in that repository you can see up here i'm in the terraform projects repository and these are the files in that repository right now the first file we have in this repository is the dot ignore file and the second file is the readme file if you want to see all the repositories in your account all you have to do is click on this logo and all the repositories in your account will show up here if you want to go into any particular repository just select it and it will take you into that repository now that we have created our github repository we will clone the repository to our local computer cloning means that you are creating an identical copy of your github repository on your local computer so when you clone a github repository all the files in the repository are downloaded to your computer to allow you to work with those files easily to clone a github repository you must install git on your computer to install git on your computer go to google and in google type git in the search box once you type git press enter on your google search results under git and the url is git iphone scm.com click downloads on this page under downloads you can select the link for any operating system you want to download git to since i'm downloading git to my windows computer i'll select windows on this page click this link once you click this link it is going to download the git executable file to your computer and you can see it here i'm going to right click on it and click show in folder and it is going to open the folder the executable file is downloaded to on my computer just in case if you don't see this on the lower left hand of your computer the executable file is usually downloaded to your downloads directory so go to your downloads directory and you should see it there once you come to that directory and you see the executable file double click on it to start the installation process then click yes then click next click next again and click next again so from here i'm just going to click next all the way to the end i'll click next next next next then here click install it is now installing git on my computer and i wait for the installation to be completed once git has been installed on your computer i'm going to uncheck this and click finish the next thing we need to do is verify that git was successfully installed on our computer i'm going to minimize this the first way to verify that git is successfully installed on your computer is click the start menu and type git in the search box once you type git you should see the git bash app here click it and it is going to open this for you this is one way to verify that git is successfully installed on your computer i'm going to close this another way to verify that git is installed on your computer is through the command prompt so we are going to click the start menu again and type cmd once you type cmd you will see the command prompt here and if you type cmd and you don't see the command prompt you can also type command prompt in the search box click the command prompt and in here to verify that git is installed we are going to type git space dash dash version once you type git space dash dash version press enter if you get an output that means that git is installed on your computer once you have verified that git is installed on your computer the next thing you are going to do is run this command in the terminal to configure your git username and email i will leave these commands in this video's description and before you run this command make sure you replace your first name and your last name here and also enter your email address here once you have updated those two information copy these commands and in the terminal paste it there once you paste it press enter and there you go that's all we need to do to configure our git username and email once you have installed git on your computer the next thing you will do is create a keypair to create a keypair on a windows computer first we are going to open powershell click the start menu and type powershell in the search box once you've typed powershell click the windows powershell app and it is going to open powershell to use powershell to create a keypair on your computer you will type this command this is the command you will use to create a keypair on your computer and the command is ssh iphone key gen the t means type and the type is rsa and the dash b means byte and the byte is 2048. once you type this command press enter it is now generating the public and private key the next question is asking you where you want to save your key pair to this is the default directory that your keypair will be saved to and for best practice it is always good to leave it in this directory so here just press enter the next question is asking you for a passphrase we are not going to add any passphrase press enter press enter again there you go we have successfully created the keypair remember the keypair is saved in this directory so if you go into the c user admin dot ssh folder you should see your keypair index let's open the file explorer on our computer to verify that our keypair is in that directory i'm going to click the start menu then i'm going to type file explorer so select file explorer here once you have opened the file explorer we'll select the c drive then we'll select users and according to our directory the next one is admin but on your computer this might be your name i'll select admin and on that admin it is saying dot ssh we are going to look for dot ssh it is right here i'll select it and there you go in the dot ssh folder you can see the key pair in there so anytime you see a part in here that is just referring to the same part on your computer if you look we went to the c drive c drive we click users users admin admin dot ssh dot ssh and in that directory we have our keepers in there this is how you create a key pair on your computer in the last lecture you created a keypad so the next thing you need to do is upload the public key of that keypad into github once you've done that then you will be able to clone your github repository to upload the public key of our keypair into github the first thing i want you to do is open the file explorer once you've opened the file explorer let's go to the location where we saved our keypad my keypair is on the c drive in the users folder i'll click admin and i'll click dot ssh and my key pair is in here the key we want to upload to github is the public key and it is the one with the psi so the next thing you need to do is right click on it come down to open with and select notepad so once you select that it is going to open that key here and it is a long key all you have to do is put your cursor at the start then press ctrl a to select everything then right click and copy once you have copied the content of your public key make sure you don't change anything in here because it is an encryption key the next thing i want you to do is close this file i'll close it and i'm going to go back to github once you've logged into your github account we'll select this logo up here and select settings under settings select ssh and gpg keys under ssh keys select new ssh key then give the ssh key a name i'll call it my public key once you've given it a name in here we are going to paste that key pair in there and this is all you need to do first you give it a title and on that key paste the content of your public key in here once you have pasted the content of your public key click add ssh key we have successfully uploaded our public ssh key into github now that we have uploaded the public key pair into github we can clone our github repository to our computer to clone the teraform projects repository the next thing we are going to do is we are going to open the command prompt on our computer so on your computer open the command prompt once you have opened the command prompt the next thing you are going to do is change to the directory you want to clone the terraform projects repository in for example in my case i want to clone the terraform projects repository on my desktop so i will minimize this just to show you what i mean this is the desktop on my computer and i want to clone the terraform project repository on my desktop so once i open the command prompt the first thing i'm going to do is change to my desktop to change directory to my desktop i'm going to type cd space and desktop this is the command to change to the desktop and i'll press enter and now you can see i am in dc user admin desktop i've changed my directory to the desktop which is where i want to clone the terraform projects repository to once you have changed to the directory you want to clone the github repository to the next command you are going to type is git clone so type git clone once you type git clone press space then i want you to come back to your github account on your github account in the home page to get to your home page click this logo up here and that will bring you to the home page once you are on the home page the next thing you are going to do is select the repository you want to clone to your computer this is the repository i want to clone to my computer i'll select it and that will take you into that repository in that repository select code you can clone a repository using https ssh and github cli we will be using ssh to clone our repository select ssh once you have select ssh click here to copy the address then come back to your command prompt on your command prompt after git clone paste that address in there so this is what it should look like git clone and the address of your github repository so i'm going to minimize this to show you what is happening so let me move this to the side i've typed my command git clone and the address of the repository i want to clone watch what will happen on my desktop when i press enter you will notice that the repository in my github account will be cloned to my desktop here so here i'm going to press enter it is cloning the repository the first time you clone a repository it is going to ask you this question i'm going to type yes and press enter there you go the terraform projects repository in my github account has been successfully cloned to my computer and you can see it here so if i double click on this folder to open it in that folder you see i have dot ignore and a readme file and if we go to our github account in the github account in the terraform projects repository we also have a dot ignore and readme so this is how cloning a repository works we created a copy of this repository and all the contents in that repository to our local computer and that is what you are seeing here now what we can do is edit any of this file and once we make changes to this file we can push those changes back to our github repository as we move forward in this project we are going to see that this is how you clone a github repository to your computer if you have any question or there's any part of this lecture you don't understand please leave your comments below thank you and i'll see you in the next lecture bye
Info
Channel: AOS Note
Views: 27,792
Rating: undefined out of 5
Keywords: How to Clone a Github Repository using SSH, github, ssh, git, clone, gitlab, tutorial, github tutorial, git clone, java, private, ssh key, public, bitbucket, devops, github repository, github tutorial for beginners, clone github, git tutorial, learn github, how to, learn git, computer, git clone using ssh, how to clone github repo using ssh, clone git repo using ssh, git clone ssh using command line, git clone ssh using git bash, git clone ssh, aosnote, bitbucket tutorial, Terminal
Id: XA9GJVlIZDU
Channel Id: undefined
Length: 18min 57sec (1137 seconds)
Published: Thu Jul 14 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.