How to Push project from Local machine to GitLab with SSH using cmd prompt #ajautomation #git

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone so let's see how we can push the project from my local machine to gitlab repository using SSH using the command prompt so I have one main project on my local machine main profiles okay so this project I need to push to my gitlab repository so we can do that let's first login into our gitlab account so first step is to create the new project as we are pushing our new project into the gitlab repository so I will click on new project create a blank project and here you need to provide the project name okay so I'm not going to deploy anything so no deployment planned and make it as a public so that it can be accessible to everyone I will uncheck this checkbox and I will click on create project so this is the blank project we have created and repository for this project is empty so now we can push any project to this repository so what we can do is this is our local project I will open command prompt from here so to push the project to our gitlab or GitHub uh we need to uh there are two ways by which we can do that one is https and one is SSH so we have already seen how we can do with the https authentication using username and password so now we will see how we can do it with the SSH okay so currently we don't have any git local git repository in this project okay so first we need to take all this file to our local get repository you will create a empty local repository will push all these files to that local gate repository and from that local repost you are going to post our all the project to the remote repository in the gitlab so let's first create a m ticket local repository so just run this command creating it so this repository is empty okay so there are no commit set in that repository and all these files are ah need to commit first okay so to commit all these files first we need to add this file to our staging area Okay so git add space Dot so this will add all the files to our staging area and that will be ready to commit so let's commit the files Now using git commit and give some message here let's see initial commit so now if you check the status all these files will be uh are already a part of your local repository now okay so now they are ready to push to anywhere you can push it to your gitlab repository or GitHub repository anywhere okay so first we need to add the origin our remote origin so for that use git remote origin and where is your origin so we are going to push using the SSH so what you can do is you can scroll down here uh click on here just copy this URL the SSH URL okay and paste it here okay so that you can verify using the git remote when we so our origin has been created for Fetch and push operation so let me clear this okay so first let's check the branch name the git branch okay and I can use the a for all branches So currently we have this master bench this is the local Master branch in the git so we need to push it so if I try to push it directly without SSH let's see what happens so I will use git push origin master so as you can see here it is giving permission denied error okay so as we are trying to push our code from local to remote repository but we have not added any uh kind of authentication method here okay so if you are trying to push using the SSH you need to add the SSH key into the gitlab profile okay and then you will be able to push this project okay so for that purpose what you can do is first open the command prompt again so first we need to create the SSH public key and private key pair RSA keeper on our local machine so just create it using this command SSH Dash Keygen hit enter then again press enter key again press enter okay so this operation has created the public and private uh SSH key okay RSA key so if you go to the user's location in the local machine and in the dot SSH folder you will find this two keys are already available okay so this is our public key so just open this key with the notepad so this key we need to add into our GitHub gitlab profile so I have not added any SSH key until now so that's why it is showing me this ah notification as well you need to add the SSH key before you push or pull uh anything into this repository using SSH so for that purpose go to your profile go to preferences here you will find the SSH key on the left hand side click on that and here we need to add that uh key from local machine so copy all this content and just add in this text box okay and this is the usage type for authentication and signing and they have given some expiration date as well here uh after the one year okay so just add the key and click on ADD key so with the help of this SSH key which is available on my local machine I will be able to push and pull to this gitlab repository now so ah if I go to the command prompt again and here again we are trying to push the changes to our gitlab repository so I will hit enter okay so now you can see our changes has been successfully pushed to our gitlab proposity so it has created a new Branch with the name master in the gitlab and it has pushed all the changes from the local Master git repository to the remote Master branch in the remote repository okay in the gitlab so let's verify the changes I will go to the projects and let's say view all projects so you can see here all the files from our local machine project are already available in our gitlab repository now okay so this is how you can push your project from local machine to gitlab repository using the SSH so I hope this session will be helpful for all of you so let me know if you face any issue in this thank you [Applause] [Music] [Music] [Applause] [Music] thank you
Info
Channel: AJ AUTOMATION
Views: 3,145
Rating: undefined out of 5
Keywords: git push, gitlab tutorial, gitlab push with ssh, gitlab push with ssh key, commit to gitlab using ssh, gitlab ssh config, gitlab ssh connection, ssh authentication gitlab, how to push file to gitlab, push code gitlab, push project to gitlab
Id: mtP23IcE5NE
Channel Id: undefined
Length: 8min 4sec (484 seconds)
Published: Mon Jan 30 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.