Git & Github Guide for Absolute Beginners

Sk Soyeb Akhter
6 min readJun 9, 2022

So you’re a programmer and recently you have heard about git or github. In your mind you may be asking “What/why git and github? Why do I need it? How to use it? Does git and github come in combo? etc”

Don’t worry in this article I will clear all your doubts in very very simple words and show you a real world example.

Explanation

First let’s start with the easy one → Github. It is a website which can save your local project (it can be only one file or hundreds of files and folders) on their server for free. All you need to do is upload your project to its site. For example in this picture you can see that github has saved/hosted my(akhtersoyeb) project (emoji-site).

As you can see my project has two folders (public, src) and many files. Your’s can be more or less then it, doesn’t matter.

Another important note is that, on github a projects is called repository or in short repo.

So in conclusion, Github is a simple website where you can upload your project. You can also download your project whenever you want.

Next up is git. It is hard to explain but I will try. Git is tool that you can download in your local computer. It has many features like — it can save your projects history, it can be used to go in previous states(versions) of your project, it can be used to experiment with your project without harming the working version of the project. Now let me say this again → I am using simple words to explain. So may be I am skipping some features but don’t worry if you know the basics you will get the advance features also.

Real World Example

Number 1 thing that you need to do is create a account on github. Its free. Just visit github and click on signup.

Next you need to download git. For windows and mac users visit git downloads then download git then install it. It is very easy you just need to run the downloaded file by double clicking on it and follow the installer’s instructions. For linux users, you guys should have git pre-installed on your system.

After the installation of git is complete, verify that git is successfully installed and ready to be used. To do this open a terminal or command prompt window and run this →

git --version

If you don’t see a version, then you have done something wrong, Do the steps again. You should see something like this if you have successfully installed git

Another step → Run these commands inside your terminal and change accordingly :

git config --global user.name "Your Name"
git config --global user.email email@example.com

Alright, your system is ready. Lets try it in a project.

For this example I have created a folder named “demo_website”. Inside this folder is a file “index.html” and another folder called “css”. The “css” folder has two more files “style1.css” and “style2.css”. This is simple project that I have created just for a demo purpose. Project structure →

demo_website
|-- css
| |-- style1.css
| `-- style2.css
`-- index.html

Lets write something in these files [I have used vs code to write code] →

Here come’s the git part. Fit you need to initialise this project with git. Navigate to “demo_website” folder and run this in your terminal→

git init

Next we need to commit the files and folders. Now note that [only for beginners] whenever you want to commit something you need to run two commands one after another. The commands are →

git add .
git commit -m "any message you want. like: first commit"

Just like that you have created a version of your project. Now change any thing in the files. You can add new code, delete line, change code, anything. After you have made changes you need to commit again.

Now you have two saved version of your project.

Enough with the basics of git. Lets upload our project to github. First you need to create a new repository in github. So go to github.com then click on the plus(+) icon on right hand side then click on “new repository”. Give your repo a name (any name you want) then add a optional description. Don’t change other options for now. Then click on “Create Repository” Button.

After it you will see a guide of window. Don’t worry for now. Just find this section and copy the url by clicking on the copy icon on the right

Next open your terminal → Navigate to your folder and run these commands one by one :

git remote add origin your_copied_url
git branch -M main
git push -u origin main

Here is my screenshot of doing it

After running the “git push …” command you’ll be prompted for your github username and password. NOTE that password will not be visible when you type it.

If everything goes OK. Refresh your github page and you should see something like this →

With these steps you have successfully uploaded your project on github. To summarize everything

  • you created a project
  • then you initialise it the “git init” command
  • then you commit it by running these two commands
git add .
git commit -m "your message"
  • you need to run these two commands every time you want save your changes of the project as a version history
  • then you created a new github repository on github’s site
  • then you uploaded the project with these commands
git remote add origin your_repository_url_that_you_copied
git branch -M main
git push -u origin main

That’s all the explanation I can do for beginners. NOTE that this is not all the things you can do with git and github. Checkout these pages to gain more knowledge -

If you have learned something from this article please show your support by FOLLOWING ME on medium. Bye! take care. With love from India.

--

--