An Intro to Git and GitHub for Beginners Part I (Tutorial)

What is the Difference between Git and GitHub?

Git is a free and open distributed version control system, a tool to manage your source code history.

Install Git

The first thing you need to do is install Git on your Machine.


$ sudo apt-get install git


Download and install Git for Windows.

Create a GitHub Account

Step 1: Create a local git repository

A repository (or often, ‘repo’, for short) is the Git version of a project folder. Git will track any changes inside of a repository.

$ mkdir myProject
$ cd myProject
Make sure you are inside the directory you created.
$ git config --global "Your Name Here"
$ git config --global ""
$ git config --list
$ git init
Git init command creates a hidden directory “.git” in the directory where you ran it.

The 3 States of Git

Files in a repository go through three stages before being under version control with git:

  • Modified means that you have changed the file but have not committed it to your database yet.
  • Staged means that you have marked a modified file in its current version to go into your next commit snapshot.
The 3 States of Git
Git Workflow

The basic Git workflow goes something like this:

  1. Working directory/tree: The current version of your project where you are making changes (which is reflected in your code editor)
  2. Staging Area(aka Index): The place where you stage your files when you are preparing them to commit
  3. Repository: When you commit, Git permanently saves only the changes from your staging area to the repo’s memory

Step 2: Add a new file to the repo

$ touch hello.txt
ls command — shows a list of all files or folders in the current directory
$ git status
As we can see our hello.txt file is “untracked’

Step 3: Add a file to the Staging area

$ git add hello.txt
Notice the “Changes to be committed” line after we run the git status command
$ git rm --cached hello.txt
Our file is no longer in the staging area and that means it is not tracked by git

Step 4: Create a commit

$ git commit -m 'adds the hello.txt'
use git status to check the status of your repo after committing
git log
Look at your progress using the git log command

You are now using Git.


I’m just here to talk to myself and hope people are listening.