Git & Github

What is Git ?

Git is a version control system which lets you track changes you make to your files over time. Basically with git you can make a copy of a file, make changes to the copy and also revert back to before or original file.


Let’s say you are working on a website and wanted to make few changes. But at the same time, you might not want to start altering the code on the same file because it might end up making it worse.

With Git, you can create an identical copy of that file and play around with the code until you are satisfied with your changes, you can merge the copy to the original file.

Installing GIT

You can download the latest version on the official website. Download for macOS

For MacOS:

Install homebrew if you don’t already have it, then:
$ brew install git

For Linux:

For the latest stable version for your release of Debian/Ubuntu

# apt-get install git

For Windows:

Install winget tool if you don’t already have it, then type this command in command prompt or Powershell.
winget install --id Git.Git -e --source winget

To initialize your project, simply run git init. This will tell Git to get ready to start watching your files for every change that occurs.

What is GitHub?

  • GitHub is basically the largest host of source code in the world, and has been owned by Microsoft since 2018.
  • Let’s Consider you are working on a project at home and while you are away, maybe at a colleague’s place, you worked and got the solution to a code error.
  • Generally You can’t make these changes because your Laptop isn’t with you. In this case, if you have your project hosted on GitHub, you can access and download that project with a command on whatever computer you have access to. Then you will be able to make changes and push the latest version back to GitHub.

Example: Start a new repository and publish it to GitHub

First, you will need to create a new repository on GitHub. For more information, see “Hello World.” Do not initialize the repository with a README, .gitignore or License file. This empty repository will await your code.

Starting a new repository and publishing it to GitHub

# create a new directory, and initialize it with git-specific functions
git init my-repo
# change into the `my-repo` directory
cd my-repo
# create the first file in the project
# git isn't aware of the file, stage it
git add
# take a snapshot of the staging area
git commit -m "add README to initial commit"
# provide the path for the repository you created on github
git remote add origin
# push changes to github
git push --set-upstream origin main

You can Learn more about Github on the official website.

For Practise and Easy Understanding refer W3Schools

I personally learned from Harvard’s CS50 Youtube Channel.

Happy Reading :)



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store