code 101
When you start writing code, you quickly realize something:
files change, mistakes happen, and things break
So how do professional developers keep track of what changed, how it changed, how to correct it or in words, how to go back in time when something breaks?
This article simply explains:
- How Git tracks changes
- How to push code to GitHub
- How to pull data from GitHub
beginner friendly
What is Version Control
Version control is a system that keeps track of:
Every change you make to your code
When the change happened
Who made the change
What exactly was modified
Think of it like Google Docs history for your code.
If your code breaks, Git lets you correct it to a working version.
Git also helps you collaborate with other like minded individuals in shared projects.
What is GitHub?
GitHub is a cloud platform where Git repositories are stored online.
You use
Git on your computer
GitHub to back it up and share it with others
How to create a Git Repository
A repository is a folder that Git tracks.
git init
This creates a hidden .git folder inside your project.
Now Git is watching this directory.
Save a Version (Commit)
A commit is a snapshot of your project.
git commit -m "Add file"
Now Git has stored that version forever.
You can always go back to it.
Push Code to GitHub
First connect your project to GitHub:
git remote add origin git@github.com:yourname/yourrepo.git
Push:
git push -u origin main
Note: The default branch name is often main. If yours is "master"
use
git push -u origin master.
Your code is now safely stored online.
Pull Code from GitHub
If someone else updates the repository, or you work from another computer:
Navigate to your local repository directory using the command
cd
For example, if your repository is in a folder named Mombasa then,
cd Mombasa
Ensure you are on the correct branch by using the command
git status
Pull the latest changes from the remote repository using the git pull command
git pull
This downloads the latest changes into your project.
How Git Tracks Changes
When you edit a file:
git status
Git will show:
modified: Mombasa
To save the change:
git add Mombasa
then
git commit -m "Mombasa"
Git stores only what changed, not the entire file.
This makes Git fast and powerful.
Why Git is a Superpower
With Git you can
Undo mistakes
Work on features safely
Collaborate with others
Track project history
Work on multiple versions
This is why every professional developer uses Git.
conclusion
Git is not just a tool β it is how software is built.
Once you understand:
add
commit
push
pull
You can work on any real-world engineering project.

Top comments (0)