# Essentials of Git

## Git as a distributed version control system

The term version control system means it control or track the versions of the a project like commit , periodic changes and soo much more like branching to make a new feature rather than disturbing the main workflow and allowing multiples developers to work together . the word "Distributive" means every developer can have a full copy of the project and commmit it's changes so they can work and later share with each other .

## Why Only Git

There is no straight answer for this . In my oponion git is the most popular one and also it does the job pretty well

## Core Essentials Terms of Git

### Repository:

Repo is just the fancy word for the project folder . Developer can make multiple folders now called repository and then can use them as they want

## Branch :

Branch is also an another concept and a very good features . To understand this we have to imagine a live project on production and the project is working good but then the developer wants to add a new feature , he can add that feature to the main branch but that is not a good practise and sometimes can also cause the website or program to shutdown incase of any bug . This is why we use branches where we can develop the features without ever changing the main (production code) and can test it and then can push it to main .

## Head

it is also another very important concept of git . How will git know the latest commit that we had done so to solve this it uses the word head that points to the latest commit .

## Merging the Branches

So , now we developed the feature using the branch and now we want to push it to the main branch . now comes in the concept of merging . there are two ways in which we can merge the branch

## Merge & Merge --Squash

we want to combine the feature branch with the main branch we will simple use git merge but if I want to keep my history clean and do not want to the commits that i have done in the feature branch . In this case , what we can do is that we can use git merge --squash feature what will this command do it combine all the feature commmits and will make it one and then will make a new commit in the main file and in this way we wont have the history of the feature branch commits in main and our history will easy to read

## Essentials Commands

### git init

Its is the first command that we have to run in order to make the directory of the git .

### **git status**

git status tells the status of the currect directory files like if anything is changed from the last commit and weather the files are in staging area or they are comitted .

### git Add

git add is an essential command that tells the git to add that files to staging area and start tracking the files code to track the changes

### git commit -m ""

git commit is to make the changes permenantly track by the git and it is usally written with this m flag that is just for maintaing a clean code readibilty so a person can know what changes he made in a particular commit . The commit has some information like :

*name and email of the person who made the commit*

*time and date of the commit when it was made*

*the parent commits hash that is very important*

### Git log

git log shows the history of commits that are made and usually we use this command as git log --oneline . Using this command the git logs becomes more readable
