# Git for Beginners

## Before starting with Git, lets understand what version control system(VCS) means, how it helps to accelerate the development work.

## what is VCS?

A system that records the changes to files over time, allowing user to revert to a specific previous versions or review the project history.

Distributed Architecture in VCS: Unlike older, centralized system every developer has local copy of entire project history, this allow developers to work offline independently.

## What is git?

Git is free, open source distributed version control system used to track changes in computer files(most commonly source code file in software development). It allows multiple people to collaborate on a project efficiently without overwrutting each other work.

## What is difference between Git and Github?

Git → locally installed open source version control system.

Github → is web based platform that hosts git repositories and provide collaborate features.

### Commonly used/core git terminologies.

1. Git Repository
    
    It is directory that contains git and working directory that contains all files tracked by git and git repository is placed where all files are stored.
    
2. Git Working Reoistory
    
    It is directory that contains all the files that are tracked by git.
    
3. Branch
    
    Branch can be thought as an copy of main/working direectory, whenever developer start working on any project, it creates branch)i.e copy of code) and work independently and in isolated enviroment.
    
4. Checkout
    
    This is the process/command to switch between branches generallywhen developers are working on multiple features, they create seperate branch for developmen of each feature, when they need to change/switch branch checkout command is used.
    
5. Merge
    
    It is the process that involves merging of code from one branch to another branch.
    
6. Pull
    
    It is the process to pull the changes from remote branch)from github/web/cloud) to local branch
    
7. Push
    
    It is the process to push all/comitted changes from local branch to remote branch.
    

Basic Hit Commands

1. Creating new repository
    
    git init projName
    
2. Clone (Copy)an existing Repo
    
    git clone RepoName
    
3. Prepare file to commit
    
    Add untrack file/umstaged changes to stage
    
    git add filename
    
    Choose which parts of file to stage
    
    git add -p
    
    Delete file
    
    git rm filename
    
4. Commit
    
    git commit -m “commit message”
    
5. Move between branch
    
    (moving/switch to particular branch from current branch)
    
    git checkout branchName
    
6. git list of branches
    
    git branch
    
7. Delete Branch
    
    git branch -d branchName
    
8. Discard the changes
    
9. git restore fileName
