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 the above diagram, that problems like
- Easy to overwrite someone else's code
- Hard to know who changed what
- File corruption
- No proper version of history
- We can't easily go back to previous versions
so, in order to overcome all these issues git arrived.
Git Popularity
Git become so popular because it solved many programmer's problems that faced earlier
First, Git is distributed among all the developers which means every developer has a full copy of project.
Second,Git makes tracking changes very easy, Developers can see who changed the code and what was changed and when it was changed.
Third, Platforms like GitHub made Git more popular by allowing developers to store code online and collaborate from anywhere .
What is Git?
Git is a version control system that helps developers track, manage and save changes in their code. As you can see in the *Diagram *
Whenever you edit your code, Git keeps a record of what was changed ( we'll discuss it how it is done).This means you can go back to an older version anytime if something breaks or something goes wrong.
Git also makes it easy for multiple people to work on the same projects. Each person can work on their own copy of the 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 Git works and its commands we have to first look into Diagram and some core terminology 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.
it's 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 separate path to work on your code without disturbing the main work.
It's like making a photocopy of your notebook 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.
It's like a bookmark in a book showing the page you are currently reading.
Common Git Commands
1. git init
This command is used to initialize 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 have 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 a specific file
git add <filename>
// for everything
git add .
What it does:
- Selects files you want to save
- Prepares them for a 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 :
Displays 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 the last commit and the current commit.
What you changed but haven't committed yet
7. Git checkout
Used to switch branches or 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 the latest code from a 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 pushing code to a remote repository
Thanks for reading ! if enjoyed this blog , you can read more on this π




Top comments (0)