If you’re just getting into coding, chances are you’ve heard people casually throw around words like git, commit and github and thought:
“Yeah… I’ll figure that out later”
Good news: now is later and git isn’t as scary as it sounds.
So… What exactly Is git?
Git is a version control system. That's just a fancy way of saying:
Git keeps track of changes in your code over time
Think of git like a save system for your project, except:
- Every save has a message
- You can go back to any previous version
- You can see what changed, when and why
Why version control is a big deal
Version control is important because:
- Code breaks
- Features change
- Bugs appear out of nowhere
- Teams work on the same files
With git, you can: Roll back to a working version, experiment without fear, collaborate without overwriting someone else’s work and understand how your project evolved.
Basically, git lets you make mistakes safely and that’s huge.
Installing git
First things first, install git:
After installing, check that it works on cmd:
git --version
If you see a version number, you’re good to go 👍
How to push code to github
Let’s walk through a real-world flow.
Create a github repository
On github:
- Click new repository
- Give it a name (e.g. your-first-repository)
- Click create repository
That’s your online home for the project.
Setting Up Your Git Username and Email
Before you start committing code, Git needs to know who you are. If you don’t set this up, Git will eventually stop you with an error like:
Please tell me who you are.
This information is attached to every commit you make, so GitHub and other developers can see who made each change.
Run these commands:
git config --global user.name
git config --global user.email
Set your git username
git config --global user.name "Your Name"
git config --global user.email "youremail@gmail.com"
Run & you are all set
git config --global --list
Initialize git in your project - This tells git: Hey, start tracking this project.
git init
Add files to git - This means: I want git to track all current changes.
git add .
Commit your changes - A commit message should explain what you changed not your life story, hehe lol.
git commit -m "Initial commit"
Connect your project to github - This links your local project to github.
git remote add origin https://github.com/your-username/your-first-repository.git
Push your code - Boom 💥 Your code is now on GitHub.
git push -u origin main
How to pull code from github
Pulling just means - “Give me the latest version from github.”
Run this inside your project:
git pull origin main
How to track changes with git
This is where git really shines. Check the status of your project
git status
If you ever feel lost, run
git status
See exactly what changed
git diff
This shows line-by-line changes before you commit.
View commit history
git log
This shows: past commits, messages, dates and authors
Git feels confusing at first because it’s different, not because it’s impossible.
Once you understand:
add - stage
commit - save
push - upload
pull - download
…it starts to click. If you’re learning git, you’re already doing the right thing. Stick with it.
Code! Add! Commit! 🚀
Top comments (1)
If you’re learning to code and git feels confusing or intimidating, you’re not alone.
This post breaks down git and github the easy way.