# Git for Beginners: Basics and Essential Commands

**What is Git?**

Git is simply a **version control system**. It helps us **track every change** in our code and **record the history** of the project. Git keeps information about what code was changed, when it was changed, and sometimes why it was changed.  
The file system where Git is initialized is called a **repository**, and it is created using the `git init` command.

**Why Git is Used?**

* It allows safe experimentation
    
* It prevents code loss
    
* It is useful for both solo and team projects
    
* It keeps track of code changes.
    

**Git Basics and Core Terminologies?**

1. **Repository (Repo)**   
    A repository is the central storage location for a project. It contains all the project files, the history of every change made to those files, and the metadata Git uses to manage the project \[1, 2\]. 
    
2. **Commit**
    
    A commit is a snapshot of your project's entire directory structure and file contents at a single point in time \[1\]. It is the primary way you record progress in Git. 
    
3. **Branch**
    
    A branch is a lightweight, movable pointer to a specific commit. Branches allow you to diverge from the main line of development and continue work without affecting the main codebase \[1, 3\]. 
    
4. **HEAD**
    
    `HEAD` is a symbolic reference to the *current* commit you are working on \[1, 4\]. It always points to the tip of the branch you are currently checked out to. 
    

Common Git commands:

| **Command** | **Description** |
| --- | --- |
| `git init` | Initializes a new Git repository |
| `git status` | Shows the current status of files |
| `git add` | Adds files to the staging area |
| `git commit` | Saves changes permanently in the repository |
| `git log` | Displays commit history |
