Git and Github Cheatsheet


What is Git?

Git may be a free and open source conveyed adaptation control framework outlined to handle everything from little to exceptionally expansive ventures with speed and proficiency. Adaptation control framework could be a system that records changes to a record or set of records over time so that you simply can review particular forms afterwardNot at all like a central VCS, a conveyed VCS has both inaccessible and nearby stores. As a result, it does not require the reinforcement.

  1. Download Git from here
  2. Enter Configuration Values:
    $ git config --global "firstName lastName"

     – your name

    $ git config --global "[email protected]"

     – your email

  3. Check Your Settings:
    $ git config --list
To open a manual and display information about Git:

$ git help -a


$ git help --all

 – shows a list of all available commands

$ git help config

 – explains how to use the Git verb, in this case, 

$ git help -g


$ git help --guide

 – shows a list of Git guides

New Repository

To create a New Repository:

$ git init

To clone a Remote Repository:

$ git clone /Url/
Staging Area

To add / propose changes:

$ git add /file/

To add everything:

$ git add .

To remove:

$ git reset /file/

To commit changes:

$ git diff

 – shows the changes made

$ git commit -m "Detailed message explaining the nature of changes"

To push changes to remote repository:

$ git pull origin master
$ git push origin master

Git project consists of three main sections:

  1. Working Directory
  2. Staging Area / Index
  3. HEAD


Three main states of files:

  1. Committed
  2. Modified
  3. Staged


A Git branch is a movable pointer to the commits. The default branch is called master.

To create a new branch: 

$ git checkout -b newBranch

To remove a branch: 

$ git branch -d newBranch

To go back to master

$ git checkout master

To push to the remote repository: 

$ git push origin /branch/

To merge a branch to current branch: 

$ git merge /branch/

To see the commit that was just made:

$ git log

The message, author, email, and other additional information will be displayed.

Git Checkout
$ git checkout -- /file/


$ git fetch origin

 – to cancel all the commits implemented locally


4 thoughts on “Git and Github Cheatsheet”

Leave a Comment