Understanding Git
Source: Dev.to

What is Git and Why Version Control is Important
Git is a version control system that helps you manage different versions of your code in an organized way.
Why Version Control Matters
- Track changes – See exactly what changed, when, and why.
- Collaborate – Multiple people can work on the same project without overwriting each other’s work.
- Undo mistakes – Revert to previous versions if something breaks.
- Experiment safely – Try new features without breaking your main project.
How to Push Code to GitHub
Pushing means uploading your local code to GitHub.
Regular Push Workflow
# Add files to staging area
git add . # Adds all files
# Commit changes with a message
git commit -m "Added login feature"
# Push to GitHub
git push -u origin main
How to Pull Code from GitHub
Pulling means downloading the latest code from GitHub to your computer.
# Pull changes from GitHub
git pull origin main
How to Track Changes Using Git
Basic Tracking Commands
-
Check status of your files
git status -
See what changed in files
git diff -
View commit history
git log --oneline -
See who changed what
git blame filename.js