Dev Basics Lesson 2 of 3

Git Basics

What this lesson teaches

Git is version control—it tracks changes to your code over time. GitHub is where you store and share Git repositories online. Both are essential for modern development.

Why learn Git?

Git lets you save snapshots of your work, undo mistakes, and collaborate with others. Claude Code often creates commits and works with Git, so understanding the basics helps you stay in control.

First time? Install Git from git-scm.com and create a free GitHub account.

Getting started

Clone a repository

git clone https://github.com/user/repo.git

Downloads a project from GitHub to your computer.

Initialize a new repo

git init

Creates a new Git repository in the current folder.

The basic workflow

The Git workflow has three stages:

  1. Working directory — Your actual files
  2. Staging area — Changes ready to commit
  3. Repository — Saved history

Check status

git status

Stage changes

git add filename.js    # Add specific file
git add .              # Add all changes

Commit changes

git commit -m "Add login feature"

Push to GitHub

git push

Branches

Branches let you work on features without affecting the main code.

git branch feature-name    # Create branch
git checkout feature-name  # Switch to branch
git checkout -b new-branch # Create and switch

Tip: Always pull before you start working: git pull gets the latest changes from GitHub.

Key Takeaways

  • git clone — Download a project
  • git addgit commitgit push — The basic workflow
  • git status — Check what's changed
  • Branches isolate your work from the main code