# Git for Beginners: Basics and Essential Commands

## What is Git?

\= Git is a **Version Control System (VCS)**. It helps you track your code changes and save versions of your project.  
Git mostly works on your local system and you use it from terminal.

---

## Why Git is Used?

\= Git is used to:

* track code changes (who changed what and when)
    
* work in a team without messing code
    
* save project history safely
    
* go back to older version if something breaks
    

---

## Git Basics and Core Terminologies?

\= Git Basics

* **Git:** tool to manage version history
    
* **Repository (Repo):** a project folder tracked by Git
    
* **Local Repository:** repo on your laptop/pc
    
* **Remote Repository:** repo online (GitHub, GitLab)
    

Core Terms:

* **Commit:** saved snapshot of changes
    
* **Branch:** separate line of work
    
* **Main/Master:** main branch of project
    
* **Clone:** copy remote repo to local
    
* **Pull:** take latest code from remote to local
    
* **Push:** send local commits to remote
    
* **Merge:** combine two branches
    
* **Checkout/Switch:** move between branches
    
* **Staging Area:** area before commit (git add)
    
* **HEAD:** points to your current commit
    
* **Conflict:** when Git can’t auto merge changes
    

---

## Common Git Commands?

\= Repository Setup

* `git init` → start git in a folder
    
* `git clone <url>` → copy a remote repo
    

\= Daily Workflow

* `git status` → check file status
    
* `git add <file>` / `git add .` → stage changes
    
* `git commit -m "message"` → save changes
    
* `git log` → see commit history
    

\= Remote (GitHub) Commands

* `git remote -v` → view remote URLs
    
* `git push` → upload commits to GitHub
    
* `git pull` → download and merge updates
    

\= Branching

* `git branch` → list branches
    
* `git branch <name>` → create branch
    
* `git checkout <branch>` / `git switch <branch>` → change branch
    
* `git merge <branch>` → merge branch into current branch
    

---

## Basic Developer Workflow (simple)

1. Create project folder
    
2. `git init`
    
3. make changes
    
4. `git add .`
    
5. `git commit -m "first commit"`
    
6. connect remote (GitHub)
    
7. `git push`
