DEV Community

Cover image for git Cheat Sheet
Vinay Veerappaji
Vinay Veerappaji

Posted on

git Cheat Sheet

What is git?

Git is a version control management system.

Why git?

Git helps in keeping track of changes made to code.

It also synchronize code between different people.

Helps in testing the changes to code without losing the
original.

Able to revert back to any older versions of code.

What is GitHub?

GitHub is a online platform which allows to store git
repositories.
There are other websites like GitHub such as Gitlab,
BitBucket, GitBucket etc..

What is Repository?

Repository is simply a place to keep track of code and all
the changes to code.
There are two kinds of repositories, Local and
Remote. Local repository is the one that is in your
local machine and Remote repository is stored on a server like github.

Now will jump into Git commands

  • git clone 'url' : downloads the remote repository from server into the local machine
  • git init : to initialize git to the current working directory
  • git status : shows the current activity on the repository
  • git add 'filename' // 'filenames' // '.': add the files to staging area which needs to be included in the next commit
  • git commit -m "message": saves the changes made to the repository with the message
  • git push : pushes local repository to remote repository
  • git pull : pulls remote repository to local repository (for any remote changes)
  • git log : lists all the commits that have been made to the repository
  • git reset --hard 'commit' : revert backs the repository to the given commit
  • git branch 'branch name' : creates a new branch
  • git checkout 'branch name' : to switch between the branches of the repository
  • git merge: to merge the branch and master

Still there are other git commands but I listed down some of the important and commonly used.

Top comments (1)

Collapse
 
karthikrajduraisamy profile image
Karthikraj Duraisamy

Simple and clean!