Basic introduction to Git and Github

Burki
5 min readMar 6, 2021

--

Image

Git and Github are two separate things and both of them have their own ways of working.
In this blog i will reflect on these two tech, how to set it up and get it working since they are the most essential tools for developers out there.

Starting with Git it is a version control and open-source tool where you can review the changes to the code done by anyone of your members or you want to push/pull projects from github. This tool is very useful when you are working on a big project with multiple developers.

Github on the other hand is you can say a cloud storage system for your projects where you store them and you can make them public or private it’s upto you in public anyone has the access to check or pull the project from your repository while in private only you or those who have been invited has access to the repo.

Now first you need to create a repository on github following are the steps:

  1. Go to Github and click on the “+” icon on the top right.. i hope you have created a github account first 😐.

2. Okay next you have multiple options now since we are creating a repository we will proceed with the first option.

3. After that you will be directed to this page first thing is to name your repository any unique name you can give then a description if you want to it’s not neccessary at all and then private or public as we discussed above.
The last three options are also not neccessary the ReadME file is a file where you can state guidelines/copyrights or anything you want others to know. Then the .gitignore is used when you do not want to upload some sensitive files into the repository and the last is for licensing to let other know what you can do with the code or not to use it for commerical purposes.

4. After clicking on that last green button we have successfully created a repository now we move to the git part to push our project using the highlighted link.

So, i have set up html and css files in my vscode to show you guys how we push it into our repository. Now we need to install Git first yes the installation is fairly simple you can head over to this link and install Git.

Just make sure you download the right file according to your OS. Now click on the Next button for like straight five minutes and you will be good to go.

Once done with installation head over to your editor and open up a terminal and type “git init”

If you get these green U on the files means you are on the right path this is how we initialize git in our local folder.

Now we need to add these two files into staging area this means the files that are going to be a part of the next commit we will discuss about commit also Don’t Panic..🤭

We have simple command for this “git add .” this will add all the files to the staging area. Again check those files they will have a different alphabet infront of them you can tell me in the comments what you got hint it was fell on Einstein’s head..

Next we connect to the remote repository by the following command remember this last link is the link which we get after creating a repository 👆:

Now we have established a connection to the repo and we can push our project like this “git push origin main”:

But yours will not be working like this because you need to give it a email and name so it can authorize who is the crazy guy that is messing with the code.

So, git config — global user.name “You name here” and git config — global user.email “your email here” run these two commands separately and you will have now access to the previous command and can push your code easily.

Now if you move over to that repository and refresh you will see your project uploaded there.

But what is that first change written over there? I’ll explain it is change i added to the code it was done in my local repository and was uploaded again after the changes so, whenever we are working on big project when we change something in the code we need to commit and push the project again into the repository.
In order to commit first you need to make any changes in the code once done you can head over to your terminal and write these commands to save those changes with a message -m stands for the message you want to give.

Now changes are commited and i can write git push origin main to push the committed code into repository and we will have the updated code.

There are many commands for git like git log to see all the commits done you can write git — help to see other commands also.

I hope this helped you in some way although this was a very basic guide to get started with git and github.

Thank You. 😊

--

--

Burki

Hi, I am a web developer and a fellow at Jadu Jobs.