Introduction
If you’re new to software development, you may have heard of Git and GitHub, but wondered what they actually do.
This guide explains Git in simple terms, why version control is important, and how to push, pull, and track your code on GitHub — all step by step.
What Is Git?
Git is a version control system. It keeps track of changes in your code over time.
Instead of manually saving multiple copies like project_v1, project_v2, etc., Git stores every change in a history. You can go back to any previous version anytime.
Why Version Control Is Important
Version control helps you:
- Track changes in your code
- Collaborate with other developers without overwriting work
- Recover mistakes easily
- Maintain a history of your project
Git makes development faster, safer, and more organized.
What Is GitHub?
GitHub is an online platform that stores Git repositories.
It allows you to:
- Back up your code online
- Share code with others
- Collaborate on projects
- Access your projects from anywhere
Think of Git as the tool to manage versions, and GitHub as the cloud storage for your Git projects.
How to Push Code to GitHub
Initialize Git in your project
Inside your project folder, run:
git init
This sets up Git in your project so you can start tracking changes.
Check File Status
git status
This shows:
Untracked files
Modified files
Files ready to commit
Add Files to Track
Add all your files to Git staging:
git add .
Or add a specific file:
git add filename
Commit Changes
Save a snapshot of your current work:
git commit -m "Initial commit"
Always use a clear, descriptive message for your commits
Connect to Your GitHub Repository
Create a repository on GitHub (do not initialize with README) and then run:
git remote add origin git@github.com:username/repository-name.git
Replace
usernamewith your GitHub usernameReplace
repository-namewith your repository name
Push Code to GitHub
Send your local commits to GitHub:
git branch -M main
git push -u origin main
Check GitHub — your files should now appear online
How to Pull Code from GitHub
If you or someone else updates the repository, pull changes to your local machine:
git pull origin main
This keeps your local project synced with GitHub.
How to Track Changes Using Git
Check Status
git status
See which files have changes or are untracked.
View Commit History
git log
Shows all commits, authors, dates, and messages.
Typical Git Workflow
Make changes to files
git status→ check changesgit add .→ stage changesgit commit -m "Message"→ commit changesgit push→ upload to GitHub
Repeat this cycle whenever you work on your project.
Important Note for macOS Users
Git Bash is mainly used on Windows. On macOS (and Linux), you can use Terminal, which supports the same Git commands.
Conclusion
Git and GitHub are powerful tools for anyone working with files that change over time — not just developers.
They help you:
- Organize projects
- Collaborate easily with others
- Keep your work safe from mistakes
Whether you’re coding, writing, designing, or managing any project, learning Git will make your workflow smoother and more reliable. Start practicing today and take control of your work history!
Top comments (0)