# Git CheatSheet

# Difference between Git and Github?
> `Git`:- `Git` is an version control tool

`Github`:- Somewhat `Github` is a web-based web hosting web service

## Download
Download `git` from [Git](https://git-scm.com/)

## git config
> configuring user information used in all local repositories

`git config --global user.name[firstname lastname]`

## git init
> `git init` is used to initialize the git in our project it generates a folder with the name .git which stores all the information about the git stage and commits

## git remote
> `git remote -v` is used to get remote access for the Github repository

## git status
> `git status` is used to check the status of our project, it helps us to track the stage/unstaged file/folder in the project

## git add
> `git add filename` is used to add a particular file to stage and then to commit it in our Github repository

### another way
`git add .` is used to add all the unstaged files to the stage so that we can commit them all at once

## `git commit`
> is used to commit all the staged files and folders

### another way
`git commit -am "message"` is used to stage and commit in single command

## git log
> `git log` is used to check all the logs meaning it helps us to track all the commits by showing the history of the commit done in the project, it shows details like commit hash, time, date as well as the message with the commit

## git rm -cached
> `git rm -cached` is used to unstaged all the stage files and folders meaning it helps us with removing all the files and folders from the stage

### another way
`git rm -cached` filename is used to remove a particular file from the stage

## git branch
> `git branch` branch name it is use to create a new branch in our Github repository

## git checkout
> `git checkout branch name` it is uses to change / switch from one branch to another

## git push
> `git push -u origin master` is used to push the commit to master branch

### another way
> `git push origin branch name` is used to push from origin to a banch

## git merge
> `git merge -am "message"` is used to merge from one branch to other branch for Example ( main to master )

## git reset
> `git reset -hard origin/master` is used to reset to last push commit

## git pull
> `git pull` is used to pull the files and folder from remote repository to local
