
1. What is Git ..?
Git is a distributed version control system. lets see who..?
Scenario: You and your friends are building a project together
Imagine you are working on a college project with 3 friends
Problem WITHOUT Git :
One person edits the file and sends it on WhatsApp
Another edits the same file and overwrites changes
You don’t know who changed what
You can’t go back if something breaks.
Solution :
Now imagine you have a software tool on your system that works like a smart tracker.
It records what was added , removed .
It keeps a history of every change
You can go back to older versions
This software is called Git.
Distributed means:
Every person has a full copy of the project and its history on their own computer and you don’t need the internet all the time to use Git
Git tracks changes in your files the and maintains a smart record of your project’s entire history, making teamwork safe and organized.
2. Why Git is Used ..?
track changes made to source code.
maintaining version history of a project.
branching and merging for parallel development.
prevent data loss by safely storing code versions.
3. Core concept of git and terminologies :
| Term | Simple Explanation | Example : |
| Repository | A project folder that Git tracks and manages. | Your project folder like student-portal. After running git init, it becomes a Git repository. |
| Commit | A saved snapshot of your code with a message describing the change. | Similar to clicking Save in a document. Example: “Added login page”. |
| Branch | A separate line of development used to work on features safely. | main branch has stable code. login-feature branch is used to develop and test the login system. |
| HEAD | A pointer that shows your current working position in Git. | HEAD usually points to the latest commit of the current branch. |
4. Common Git Commands:
| Syntax | What it Does (Simple Words) | When to Use |
git init | Starts Git tracking in the current folder by creating a .git directory | When starting a new project |
git status | Shows the current state of files (new, modified, staged) | Before adding or committing files |
git add file_name | Adds a specific file to the staging area | When you want to save selected files |
git add . | Adds all changed files to the staging area | When all changes are ready to save |
git commit -m "message" | Saves a snapshot of staged files with a message | After git add |
git log | Shows complete commit history | To see previous versions |
git log --oneline | Shows short and clean commit history | For quick review |
git diff | Shows changes made but not staged | Before adding files |
git diff --staged | Shows changes staged for commit | Before committing |
git branch | Lists all branches | To check current branches |
git checkout branch_name | Switches to another branch | To work on different features |
git checkout -b new_branch | Creates and switches to a new branch | To start a new feature |
git remote -v | Shows connected remote repositories | When using GitHub |
git push origin branch_name | Uploads commits to remote repository | To share code |
git pull origin branch_name | Downloads latest code from remote | To sync changes |
git clone repo_url | Copies a remote repository to your system | When starting from GitHub |
Basic developer workflow using Git from scratch :

Git Workflow (Simple Explanation)
The working directory is where you create and edit files.git add moves selected changes to the staging area.git commit saves these staged changes as a snapshot in the local repository.git push uploads commits to the remote repository, while git pull brings the latest changes from remote.git checkout is used to switch branches or restore files.
Flow:
Working Directory → Staging Area → Local Repository → Remote Repository
Basic Steps Using Commands
Initialize or clone a repository
git initorgit clone <url>Make code changes
Edit files in your editorCheck status
git statusStage changes
git add .Commit changes
git commit -m "message"Push to GitHub
git push origin main




