Hey everyone, welcome back to the channel
Today we will show you how to install git on Ubuntu 22.04, then clone a repository from GitHub
This is a fundamental skill for DevOps engineers and the developers collaborating on the code
Well, what is git? Git is a powerful version control system that tracks the changes in your code over the time
Git allows you to see the history of your code, revert back to the previous versions
if needed, collaborate with others on the projects, share the code securely on a platform
like GitHub. Let's jump into the installation steps of git. Open the terminal and run the apt command to install git
Git and its dependencies are available in the default apt repositories of Ubuntu 22.04
so its installation is straightforward. Run sudo apt update
Now run sudo apt install git-y
So this command will install git along with all the dependencies. Ok, once the git is installed, verify its version, run git space hyphen hyphen version
The output confirms that we have installed a git version of 2.43.0
Now move to the demo part. But before moving to demo part, we have to complete few prerequisites like we need to
generate the SSH keys for this user and upload it onto the GitHub portal
For that run the command ssh hyphen keys in hyphen trsa, hit enter, enter, enter, enter
So public key is saved on this file. So add this file, copy the content
Now switch to your GitHub portal. Under your account, go to the settings, SSH and GPG keys, click on new SSH key
Paste the content here. Give the title as let's say git demo
Click on add SSH key. Now move back to the terminal
In order to use git, it is recommend to configure your identity first like username, email
So run the following git commands like git config hyphen hyphen global user dot name
followed by your username, hit enter
Next similarly define your email, run git config hyphen hyphen global user dot email
followed by your email address, hit enter
Next clone the repo. Now again move to your GitHub portal
Under the repository section, let's say I want to clone this git demo repo
Click on this repo. Under the code, use ssh clone. So copy this line and run git clone, git clone and paste the content
Now hit enter. What it will do, it will clone the repo, it will create a folder on the current working
directory with the name git demo and it will clone the whole content inside that folder
If you do right. Now move to this git demo folder
Let's create a file, touch demo dot txt
Now run git status. Now git status command confirms that you have a one file demo dot txt which is untracked
Next run git space add dot. Again run git status ok
It says a new file is ready for the I mean for the commit
So for to commit these local changes, run git commit hyphen m any information message
demo txt text file, hit enter
Now push these changes to your github repo using a command git push
Run git push hyphen u space origin and then master
So what it will do, it will push your local changes to the master branch on your github account
To cross verify, now head back to your github account and if you do a refresh, you will
see a new file demo dot txt. It's one minute ago
That's it. You have now installed git on your ubuntu 22.04 and successfully cloned your first github repository
This is just the beginning of your git journey. There are many powerful commands you can learn to manage your code effectively
If you have found this video tutorial informative and useful, please do like the video and subscribe
to our channel. Feel free to post your queries and comments in below comment section
Bye for now