Courses Curriculum Cities Blog Enroll Now
Git & GitHub for AI Projects · Day 1 of 5 ~35 minutes

Day 1: Git Basics: Track Every Change

Set up Git, make your first commits, and understand the version control workflow that every AI developer uses daily.

1
Day 1
2
Day 2
3
Day 3
4
Day 4
5
Day 5
What You'll Build

A properly initialized Git repository for an AI project, with a .gitignore, a commit history showing meaningful messages, and your first remote push to GitHub.

1
Section 1 · 8 min

Why Version Control Matters for AI

AI projects are uniquely messy. You'll experiment with different prompts, swap models, tune parameters, and refactor code constantly. Without Git, you're flying blind — one wrong change and you can't get back to the version that worked.

Git gives you a time machine: every commit is a snapshot you can restore. It also enables collaboration, deployment pipelines, and professional workflows that employers expect.

The rule: If you wrote code today and didn't commit it, you don't own it. Disk failures, accidental deletes, and "what did I change?" moments are all solved by Git.

Install Git

bashterminal
# Mac (if not installed)
xcode-select --install

# Or via Homebrew
brew install git

# Verify
git --version
# git version 2.43.0

# Set your identity (one-time setup)
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
2
Section 2 · 10 min

Initialize a Repo and Make Commits

Every Git project starts with git init. This creates a hidden .git folder that stores all history. You then stage changes and commit them with a message.

bashterminal
# Create an AI project folder
mkdir my-ai-project && cd my-ai-project
git init
# Initialized empty Git repository in .../my-ai-project/.git/

# Create a Python file
echo "# My AI Project" > README.md
touch main.py

# Check what Git sees
git status
# Untracked files: README.md, main.py

# Stage all files
git add .

# Commit with a message
git commit -m "Initial project setup"
# [main (root-commit) a1b2c3d] Initial project setup

Commit message rule: Use the imperative mood. "Add error handling" not "Added error handling". Future-you will thank present-you.

3
Section 3 · 8 min

The .gitignore File — Critical for AI Projects

AI projects have files you never want in version control: API keys, model weights, virtual environments, and output files. The .gitignore file tells Git to skip them.

text.gitignore
# Python environment
venv/
.venv/
__pycache__/
*.pyc

# Secrets — NEVER commit these
.env
*.env
secrets.json

# AI/ML artifacts
*.pkl
*.h5
models/
checkpoints/
outputs/

# Data (usually too large)
data/raw/
*.csv

# OS files
.DS_Store
Thumbs.db

# IDE
.cursor/
.vscode/settings.json

Warning: If you accidentally commit a .env file with your Anthropic API key, rotate the key immediately. Even if you delete it in a later commit, it exists in Git history.

4
Section 4 · 9 min

Push to GitHub

GitHub stores your repo in the cloud. You get backup, collaboration, and the ability to deploy from it. Create a repo on github.com (no README, no .gitignore — you have those locally), then connect it:

bashterminal
# After creating repo on github.com
# Connect your local repo to GitHub
git remote add origin https://github.com/yourusername/my-ai-project.git

# Rename default branch to main (best practice)
git branch -M main

# Push your commits to GitHub
git push -u origin main
# Branch 'main' set up to track remote branch 'main' from 'origin'.

# Future pushes are just:
git push

The -u flag sets the upstream tracking, so future git push and git pull commands know where to go without extra arguments.

What You Learned Today

  • Installed Git and configured your identity
  • Created a repo with git init and made meaningful commits
  • Built an AI-project .gitignore that protects secrets and ignores artifacts
  • Connected your local repo to GitHub and pushed your first commit
Your Challenge

Go Further on Your Own

  • Add a .env.example file that shows required env vars without real values
  • Write a meaningful README.md that explains what the project does and how to run it
  • Make 3 more commits practicing good commit messages
Day 1 Complete

Nice work. Keep going.

Day 2 is ready when you are.

Continue to Day 2
Course Progress
20%

Want live instruction and hands-on projects? Join the AI bootcamp — 3 days, 5 cities.

Finished this lesson?