Hello everyone!đ¤
Before directly diving into the topic I just want to give a small glimpse of âwhat is git basically?â. For this, you need to know about version control. OMG!! Donât panic. Here is a simple way for you to understand.đ
Version control(VCS) is a software that keeps track of all modifications you make for a particular code. For instance, Rina is working on a project and created a folder which contains all the files/code related to her project. At some point, she thought of making changes to the file and she proceeds. But now, her boss needs the earlier version of code. What to do now?đ. She had already made changes to her file and she hardly remembers where the changes are made.
This is the place where version control comes into play. Version Control records/tracks every change you make to a particular file/folder. So, Rina can travel back to earlier versions easily whenever she needs.
Git
Git is one of a free and open-source distributed version control system, developed to maintain every detail of your project and it is most popular among other VCSâs, as it is comparatively easy to learn. Git even handles large projects with great speed and efficiency.
Woah! now you have basic knowledge of this. Letâs look deeperđ. The following concept(Adding SSH Key) will be ignored by many while learning git. So, if you have not done this yet do this along with me (teamwork).đ
Requirements
- Sign-in to your github account
- Create a new repository(you can use existing repo if u have one) by clicking new on left side top.
- Install git to your PC (Iâm using version 2.27.0).
Adding an SSH Key
When you are working with github repository using commands, you will often need to identify yourself with username and password always. Instead, you can use SSH key as an alternate way to identify yourself. Therefore, there will be no need to enter the username and password every time.
SSH keys come in pairs, a public key that gets shared with services like GitHub, and a private key that is stored only on your computer. If the keys match, youâre granted access.
- Open git bash, type the command given below. In place of âyour_email@example.comâ use your mail which is associated with github. This command will create a new SSH using your email as a label.
$ ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
- After executing the above code, it will show as âEnter a file in which to save the key.â Just click enter so it will take default location(recommended) or you can specify a location.
- Next, prompt will ask you like thisđ. It is just like a password, enter anything you like. The phrase you entered should be remembered.
> Enter passphrase (empty for no passphrase): [Type a passphrase] > Enter the same passphrase again: [Type passphrase again]
- At this point, a new key will be generated in the specified location. Add the new ssh key to ssh-agent. The ssh-agent is another program that is part of the SSH tool suite and it is responsible for holding private keys.
- First, check whether the ssh-agent is running by
$ eval "$(ssh-agent -s)"
- Now, the following command will add the SSH key to ssh-agent( /.ssh in code is the default folder, you use the location where you have saved the ssh key ). Then, it will ask you to type the passphrase again. Go ahead! It will show as âidentity has been addedâ.
$ ssh-add ~/.ssh/id-rsa
- Now, copy the public key from the folder and paste it in github (github->settings->ssh and gpg keys->add new key->paste and click âADD ssh keyâ).
Thatâs it! You have learnt how to add an SSH key. Pat yourselfđ