At some point, every new programmer saves files like this:
final.jsfinal_v2.jsfinal_v3_real.js
That’s when you realise you need a better system.
That system is version control.
And Git is the most popular one.
What Is Version Control?
Version control is a way to track changes made to files over time.
It lets you:
• See what changed
• Go back to older versions
• Work without fear of breaking things
Instead of guessing what went wrong, you can always rewind.
So, What Is Git?
Git is a tool that provides version control.
It records snapshots of your project as you work, so you always have a history of changes.
Think of Git as a time machine for your code.
A Simple Analogy
Imagine writing a document.
Every time you make progress, you click Save Version.
Later, you can:
• Compare versions
• Undo mistakes
• Restore an earlier draft
Git does exactly this, but for code.
Why Git Is So Important
Without Git:
• One mistake can break everything
• Team collaboration becomes risky
• Debugging is painful
With Git:
• You experiment safely
• You track every change
• You collaborate without overwriting others’ work
That’s why Git is used everywhere — from small projects to huge tech companies.
A Real Developer Scenario
You’re adding a new feature.
You change multiple files.
Something breaks.
With Git:
• You see exactly what changed
• You undo only the problematic part
• Your app is back to working state
No panic. No guesswork.
Git vs GitHub (Common Confusion)
This trips up beginners.
• Git is the tool that tracks changes
• GitHub is a platform that stores Git projects online
You can use Git without GitHub.
GitHub just makes sharing and collaboration easier.
What Git Is NOT
Git is not:
• A programming language
• A backup system only
• Something only “advanced” developers use
If you write code, Git is for you.
One Thing to Remember
If you remember only one thing:
Git keeps track of your code’s history so you can move forward without fear.
Common GIT commands for you to use
* git push origin master -> push data to origin master branch
* git pull origin master -> fetch data to origin master branch
* Git checkout -b name_of_branch -> To create new branch and and checkout the branch at the same time. It is basically a combination of the following:
1) git branch name_of_branch
2) git checkout name_of_branch
* git checkout name_of_branch -> To checkout an existing branch
* git diff name_of_branch_first.. name_of_branch_second ->compare the branches
* git log --all --graph --decorate -> Log all the information in beautiful manner
* git log --all --graph --decorate —oneline -> Log all the information in beautiful manner in one single linear manner
*git branch -> states all the branches available right now
* git branch -vv -> states all the branches available right now with some more information
*git push -u origin name_of_branch -> Set the upstream using the -u flag when pushing the content for the first time or set the upstream using the following:
*git branch —set-upstream-to origin/name_of_branch
*git merge name_of_branch -> to merge the latest branch into the master branch
*To remove local untracked files from the current Git branch
1) To see which files will be deleted run git clean -n
2) To delete the files run git clean -f