# Basics and Essential Commands

When you start learning programming, one common fear is:

> “What if I break my code?”

This happens to every developer — beginners and professionals alike. That’s exactly why **Git** exists.

Git helps developers **track changes**, **save progress**, and **work safely** on projects without fear of losing code. In this article, we’ll understand Git from scratch, using simple language and practical examples.

## What is Git?

**Git** is a **distributed version control system**.

In simple words:

> Git is a tools that keeps history of your code so you can track changes, go back in time, and work confidenatlly.

Instead of manually saving files like:

* [`project-final.zip`](http://project-final.zip)
    
* [`project-final-final.zip`](http://project-final-final.zip)
    

Git automatically manages versions for you.

## Why Git is Used

Git is used because it allows developers to:

* Track every change in code
    
* Undo mistakes easily
    
* Experiment without breaking the main code
    
* Collaborate with other developers
    
* Maintain a clean project history
    

Almost every professional software project uses Git.

## Git Basics & Core Terminologies

Before using Git commands, it’s important to understand some basic terms.

### Repository (Repo)

A **repository** is a folder that Git tracks.

* It contains your project files
    
* It also stores the complete history of changes
    

---

### Commit

A **commit** is a snapshot of your code at a specific point in time.

Think of it as:

> “Save game progress”

Each commit has:

* A unique ID
    
* A message describing the change
    

---

### Branchs

A **branch** is a separate line of development.

It allows you to:

* Try new features
    
* Fixs bugs
    
* Experiment safely
    

Without affecting the main code.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1769536171854/5e6d6cdf-c221-4be5-ab8d-1d3f90297a5e.png align="center")

---

### HEAD

**HEAD** is a pointer that tells Git:

> “You are currently here”

It usually points to the latest commit of the current branch.

## Git Workflow (Very Important)

Git works in three main areas:

1. **Working Directory** – Where you edit files
    
2. **Staging Area** – Where you prepare files
    
3. **Repository** – Where commits are stored
    
    ## Common Git Commands (With Examples)
    
    Let’s look at the most important Git commands every beginner should know.
    
    ---
    
    ### 1\. `git init`
    
    Initializes a new Git repository.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1769536303977/8bf029ac-1004-4957-8815-0842c55e171c.png align="left")
    
    This command tells Git:
    
    > “Start tracking this project”
    
    ---
    
    ### 2\. `git status`
    
    Shows the current state of your project.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1769536352784/920e3ca2-ca21-4328-9305-0b6bccea2900.png align="left")
    
    It tells you:
    
    * Which files are modified
        
    * Which files are staged
        
    * What Git expects next
        
    
    ---
    
    ### 3\. `git add`
    
    Moves files to the staging area.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1769536463753/eac185d5-fb34-400f-aa2e-adb7e46177ac.png align="left")
    
    Or add all files
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1769536495554/7766ec26-2b60-47c9-ba87-78f9126efafb.png align="left")
    
    ### 4\. `git commit`
    
    Saves your staged changes permanently.
    
    git commit -m "Initial commit
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1769536537132/abbdecf0-b6de-4960-a557-a3d758ff01b9.png align="left")
    
    A good commit message clearly explains **what changed**.
    
4. ### `git log`
    
    Shows the commit history
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1769536591853/8b180f36-717d-4cf9-afab-bd496f6dddb6.png align="left")
    
    You can see:
    
    * Commit IDs
        
    * Author
        
    * Date
        
    * Messages
        
    
    ---
    
    ## Basic Developer Workflow Using Git
    
    Here’s how a beginner typically uses Git:
    

1. Create or update files
    
2. Check status
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1769536671918/1921f5fe-883e-41a4-83f5-13a16eef5898.png align="left")
    
    3. Add file
        
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1769536712223/6f9597fc-d446-41bd-a4d9-80a788015c42.png align="left")
    
    4. Commit changess
        
        ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1769536755678/b58bec64-6d94-49d3-9464-f87f485263c5.png align="left")
        
        5. Repeat as you build features
            
    
    This simple flow builds strong Git habits.
    
3. ## Common Beginner Mistakes in Git
    
    * Forgetting to commit changes
        
    * Writing unclear commit messages
        
    * Editing files without checking status
        
    * Being afraid of making mistakes
        
    
    Remember: **Git exists to protect you**, not punish you.
    
    ---
    
    ## Where Git Fits in Real Development
    
    Git is used in:
    
    * Frontend projects
        
    * Backend APIs
        
    * Mobile apps
        
    * Open-source contributions
        
    
    Platforms like **GitHub**, **GitLab**, and **Bitbucket** are built on top of Git.
    
    ---
    
    ## Final Thoughts
    
    Git may feel confusing at first, but once you understand the basics, it becomes a powerful safety net.
    
    Start small:
    
    * Commit often
        
    * Write clear messages
        
    * Practice daily
        
    
    With time, Git will feel natural — just like coding itself.
    

## Happy coding :)
