How to get started with Git and Github?
3 min read

Welcome to the first blog on the #GetStartedWithGit Series. In this blog, you will get to know the working of Git and how to setup Git for the first time.

Use Case - A web developer or a graphic designer needed to record various versions of a specific file so that they could compare different versions and select the best one.
Originally, the straightforward way was to just create another copy of the file make changes to it, and then use it. Like this:

But as it was too clumsy to handle, there was a need to create a system that would handle this, without the need to create a new copy of the file.
TADA! Here comes Version Control
What is Version Control?
Version Control is a system that records modifications to a file or a repository (folder of files) over time so that you can recall specific versions of that later.
What is Git?

Git is a distributed version control system (DVCS) whose goal is to track and manage file changes and collaborate with multiple developers working on the same project.
A distributed version control system decentralizes the data, and every client computer not only records the snapshot of the latest files but fully mirrors the repository.
You might also have come across the term - Github. But, its not the same as Git.
So, What is Github?

Github and similar services like Gitlab or BitBucket are websites that hold a Git server program to hold your code.
Git Basics
Git stores snapshots of files at every interval and not differences. So, if a file has not changed in some interval, it reuses the same file instead of creating another copy.

The 3 main states
Modified - It means that you made changes to the file, but did not stage those changes.
Staged - It is an area where snapshots of files are added temporarily so that they are ready to be committed/ saved permanently.
Committed - It means taking a permanent snapshot of the files that are staged. It also means saving the files in your Git Version Control System.

But, we also need to know few things -
Local/ Working Directory - It is the directory that you work with on your local computer. These files are pulled from the database in the Git Directory and placed on the disk on your computer for you to modify or this directory is directly synced with another newly created repository on Github and thus works as a Git Repository.
Git Directory - It is where Git stores the metadata and object database for your project.
Staging area/ Index - This is a file that stores information about what will go into your next commit.
Basic Git Workflow
You modify files in your working directory.
You stage the files, adding snapshots of them to your staging area.
You do a commit, which takes the files as they are in the staging area and stores that snapshot permanently to your Git directory.
First Time Git Setup
If you are on ubuntu, the process is pretty straightforward. Just open your terminal and type -
sudo apt-get install git-all
To get a list of settings you can type
git config --list
to check your preferred editor you can type
git config core.editor
To set the username, email address and the editor (I would highly encourage using vim as it is great, though nano will work fine too)
git config --global user.name "Shreyas Taware"
git config --global user.email shreyastaware13@gmail.com
git config --global core.editor vim
Once this is done, we are good to go. But wait, we need to figure out a way if we are stuck.
Getting Help using Git
git help <verb>
git <verb> --help
man git-<verb>
Try this:
git help config
Part 2 of the series will be coming shortly.