What is Git? How to Push Your First Code to GitHub (Beginner Guide 2026)
Learn what Git is, how to install it, and how to push code to GitHub — step by step. Real commands, no assumed knowledge. The complete beginner's guide to version control in 2026.
Git is the tool that lets you track every change you make to your project — who changed what, when, and why. GitHub is where those changes live online so you can access them from anywhere, share them with others, or roll back to any earlier version.
Every developer uses Git, every day. This guide gets you from zero to your first pushed commit.
A full walkthrough of Git and GitHub from installation to your first push.
What is version control?
Without version control, you end up with folders like this:
Git replaces all of that. You keep one version of your files. Git tracks every change invisibly in the background, and you can jump back to any point in the history instantly.
Step 1: Install Git
On macOS
Open Terminal (press Cmd + Space, type "Terminal", press Enter).
Check if Git is already installed:
bash
git --version
If you see a version number like git version 2.45.2, you're done. Skip to Step 2.
If not, install it with Homebrew. First install Homebrew if you don't have it:
Use the token as your password when Git prompts you.
After a successful push, refresh your GitHub repository page. Your README.md is there.
The daily Git workflow
Once your project is set up, your day-to-day workflow is:
bash
# 1. Make changes to your files# 2. See what changed
git status
# 3. Stage the changes
git add .
# 4. Commit with a message
git commit -m "Describe what you changed"# 5. Push to GitHub
git push
After the first push with -u origin main, you only need git push from then on.
Commands you'll use most
Command
What it does
git status
Show what's changed and what's staged
git add .
Stage all changed files
git add filename
Stage one specific file
git commit -m "message"
Save a snapshot with a description
git push
Upload commits to GitHub
git pull
Download latest changes from GitHub
git log
Show commit history
git log --oneline
Show commit history, condensed
git diff
Show line-by-line changes not yet staged
What to do when something goes wrong
Accidentally staged the wrong file:
bash
git restore --staged filename
Want to undo your last commit (but keep the changes):
bash
git reset HEAD~1
Check where your remote is pointing:
bash
git remote -v
Clone an existing GitHub repository to your computer: