1 Hour Guide1 Hour Guide
Remaining:60 min
Back to Tutorials
💻 Code60 minBeginnerMay 2, 2026

1 Hour to Git Basics

Master Git in 60 minutes. From zero to branches, merges, and pushing to GitHub — the commands you actually need.

#git#github#version-control#cli

By the end of this hour, you'll confidently use Git for your own projects. No theory about DAGs or internals — just the commands that matter 95% of the time.

🎯 What You'll Build

A real Git workflow:

# Clone, branch, commit, push, PR
git clone ...
git checkout -b feature/login
# ... edit files ...
git add .
git commit -m "Add login page"
git push -u origin feature/login
# Open PR on GitHub

⏱️ Time Breakdown

010min
Install Git & setup
1025min
Init, add, commit
2540min
Remote + push to GitHub
4055min
Branches & merging
5560min
Undo mistakes

📋 Prerequisites

  • Terminal basics (cd, ls)
  • A GitHub account

Step 1: Install Git (0–10 min)

Check:

git --version

If not installed:

# Mac
brew install git

# Ubuntu/Debian
sudo apt install git

Windows: Download from git-scm.com.

Configure your identity:

git config --global user.name "Your Name"
git config --global user.email "you@example.com"
git config --global init.defaultBranch main

Checkpoint

Run git config --global --list. You should see your name and email.

Step 2: Your First Repo (10–25 min)

mkdir my-project && cd my-project
git init
echo "# My Project" > README.md
git add README.md
git commit -m "Initial commit"

What just happened:

  • git init → turned this folder into a repo
  • git add → staged the file for the next commit
  • git commit → saved a snapshot with a message

Make more changes:

echo "Second line" >> README.md
git status          # Shows what changed
git diff            # Shows line-level changes
git add README.md
git commit -m "Add second line"

View history:

git log --oneline

Checkpoint

You should see at least 2 commits. Try git log --oneline --graph for a visual.

Step 3: Push to GitHub (25–40 min)

Create a repo on github.com/new:

  • Name: my-project
  • Don't initialize with README

Connect and push:

git remote add origin https://github.com/YOUR-USERNAME/my-project.git
git branch -M main
git push -u origin main

From now on, just:

git push

Pull changes from remote:

git pull

Checkpoint

Refresh your repo page on GitHub. Your files are there.

Step 4: Branches & Merging (40–55 min)

Branches let you work on features without affecting main.

# Create and switch to a branch
git checkout -b feature/hello

# Make changes
echo "console.log('hello')" > hello.js
git add .
git commit -m "Add hello script"

# Push the branch
git push -u origin feature/hello

Merging (two options):

Option A: Via Pull Request (recommended for teams)

  1. On GitHub, click "Compare & pull request"
  2. Review → Merge

Option B: Local merge (solo work)

git checkout main
git merge feature/hello
git push

Delete merged branch:

git branch -d feature/hello
git push origin --delete feature/hello

Checkpoint

Create a branch, commit something, merge back to main. You should see the changes on main.

Step 5: Undo Mistakes (55–60 min)

Undo unstaged changes (file not yet git add):

git checkout -- filename
# or
git restore filename

Unstage a file (after git add):

git reset HEAD filename
# or
git restore --staged filename

Amend last commit (forgot a file or typo in message):

git add forgotten-file
git commit --amend

Undo last commit (but keep changes):

git reset --soft HEAD~1

Nuke last commit entirely (⚠️ careful):

git reset --hard HEAD~1

🎉 You now know 95% of daily Git!

🎁 Bonus

Stash uncommitted work:

git stash          # Save changes
git stash pop      # Restore them

Useful aliases:

git config --global alias.s status
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.lg "log --oneline --graph --all"

.gitignore — never commit these files:

node_modules/
.env
*.log
.DS_Store

📚 Next Steps

1 Hour to Deploy Your First Site
Get your first website live on the internet in 60 minutes. Free, with HTTPS, auto-deploys on git push.
60 min
1 Hour to Python Basics
Go from zero to writing your first real Python script in 60 minutes.
60 min

🔗 Resources