I am sure you've heard a lot about the the term Git, so in this blog we discuss
Table of Contents
- What is Git
- Why Git is Used
- Git Basics and Core Terminologies
- Common Git Commands
So first before we hopped into what is Git we have to discuss Why Git and Why it is so popular?
Why git?
So earlier when we Dont have git we have to share our code via pen drive , Zip file or FTP(File Transfer Protocol) servers.
Diagram Representation
As you can see from above diagram that problems like
- Easy to write someone elso code
- Hard to know who change what
- File curroption
- No proper version of history
- We Dont go to previous versions easily
so in order to overcome from all these issues git arrived.
Git Popularity
Git becomes so popular as it solved many programmers problem that faced earlier
First, Git is distributed to all the developers which means every developer has a full copy of project.
Second,Git makes tracking changes very easy, Developers can see who change their code and what changed and when it changed.
Third, Platform like Github made Git more popular by allowing developers to store code online and collaborate from any where .
What is Git?
Git is a version control system that help developers track, manage and save changes in their code. As you can see on *Diagram *
Whenever you edit your code, Git keep a record of what was changed ( we'll discuss it how it is done).This mean you can go back to an older version anytime if something breaks or goes something wrong.
Git also makes it easy for multiple to work on same projects.Each person can work on their own copy of th code and later combine their changes safely.
Git is like a history book for your code.
Git Basics and Core Terminologies
In order to learn how the git works and their command we have to first look into Diagram and some core terminologies with real life examples
Repository :- A repository is just a folder where your project lives and Git keeps track of everything inside it.
It's like a notebook where every time you edit a page , a copy of the old page is safely saved.
Commit :- A commit is like a checkpoint . It is like saving your recent work with a note.
its like clicking save in a game -you can always come back to the saved point with a note
Branch :- A branch is like creating a seperate path to work on your code without disturbing the main work.
It' like making a photocopy of your notebok to experiment on , while the original stays unchanged.
Head :- Head is like a pointer that tells you where you are right now. Head shows the current place you are working on git.
Its like a bookmark in a book showing the page you are currently reading.
Common Git Commands
1. git init
This command is used to start Git in a project.
git init
What it does:
- Turns a normal folder into Git repository
- Git starts tracking files in this folder
2. git status
This command shows the current state of your project.
git status
What it tells you:
- which files are changed
- which files are staged
- what is ready to be committed
3. git add
This command is used to add changes to the staging area.
//for specific file
git add <filename>
//for everything
git add .
What it does :
- Selects file you want to save
- Prepares them for commit.
4. git commit
This command saves your changes permanently.
git commit -m "initial commit"
What it does:
Creates a snapshot of your project.
Stores it in Git history with a message.
5. git log
This command shows the history of commits.
git log
What it does :
Display all commits.
Shows who changed what and when.
6. git diff
This command shows what exactly changed in your files.
git diff
What it does :
Shows the difference between last commit and current commit.
What you changed but didn't commit yet
7. git checkout
Used to switch branches ot go back to an old commit
git checkout branch_name
What it does :
Moves you to another branch
Changes your working files to match that branch
8. git pull
Used to get latest code from remote repository.
git pull
What it does :
Downloads new changes
Updates your local project
9. git push
Used to send your code to remote repository.
git push
What it does
Uploads your commits
Makes your changes visible to others
Workflow of git pushing code to remote repo




Top comments (0)