Index Ai Academy
Phase 0 · ToolsDeveloper tools

Version control with git

About 30 minLooking ahead: some prerequisites aren't done yet

Why this matters

Every AI project you'll download, from a small prompt library to a model's training code, lives in a git repository, usually on GitHub. Git is also your safety net. Before you let an AI assistant edit your code, make a commit. Then you can always see exactly what it changed, and get back to the version that worked.

  • Turn a folder into a git repository and save snapshots of it with commits
  • Explain the working directory, the staging area and the commit history
  • Read git status, git log and git diff to see what changed
  • Try an idea safely on a branch

Snapshots instead of final_v3_REAL.docx

You've probably seen a folder like this: landing-page-v2.html, landing-page-v2-edits.html, landing-page-FINAL.html. Version control fixes that mess. Git records snapshots of a whole folder over time. Each snapshot is called a commit, and it stores exactly what every file looked like at that moment, plus a short message saying why it changed.

A folder whose history git is tracking is called a repository (or "repo"). With one you can:

  • see every change ever made, when, and why;
  • get back any earlier version of any file;
  • try risky ideas without breaking the version that works;
  • share the project and combine work from several people.

Git is the program on your computer. GitHub is a website that stores copies of git repositories online and adds collaboration features on top. You can use git without GitHub, but most teams use both.

Three places a change can be

Git asks you to choose what goes into each snapshot. So a change moves through three places:

PlaceWhat it isHow things get there
Working directoryyour files as you're editing them right nowyou edit a file
Staging areathe changes you've picked for the next commitgit add
Historythe saved commitsgit commit

Think of packing a box to ship. The working directory is your desk, with everything spread out. git add puts chosen items in the box. git commit seals the box and writes a label on it. Things left on the desk aren't in the box, even if you changed them.

The command you'll run most is git status. It tells you which files changed, which changes are staged, and which files git isn't tracking yet. When in doubt, run it.

git init                        # start tracking this folder (once per project)
git status                      # what's changed? what's staged?
git add index.html              # stage one file
git add .                       # or stage every change in this folder
git commit -m "Add landing page"   # save the staged changes as a commit
git log --oneline               # list commits, newest first

Try it below. The landing-page folder isn't a repository yet.