Git & Collaboration
Version control is not optional. Every experiment, every model, every lesson you build here gets tracked.
Prerequisites: Phase 0, Lesson 01
Video coming soon
An AI-narrated walkthrough for this module is on the way. Everything you need is in the lesson below.
#Learning Objectives
- Configure git identity and use the daily workflow of add, commit, and push
- Create and merge branches for isolated experiments without breaking main
- Write a
.gitignorethat excludes model checkpoints and large binary files - Navigate the commit history with
git logto understand project evolution
#The Problem
You're about to write hundreds of code files across 20 phases. Without version control you will lose work, break things you can't undo, and have no way to collaborate with others.
Git is the tool. GitHub is where the code lives. This lesson covers what you need for this course and nothing more.
#The Concept
sequenceDiagram
participant WD as Working Directory
participant SA as Staging Area
participant LR as Local Repo
participant R as Remote (GitHub)
WD->>SA: git add
SA->>LR: git commit
LR->>R: git push
R->>LR: git fetch
LR->>WD: git pull
Three things to remember:
- Save often (
git commit) - Push to remote (
git push) - Branch for experiments (
git checkout -b experiment)
#Build It
#Step 1: Configure git
git config --global user.name "Your Name"
git config --global user.email "you@example.com"#Step 2: The daily workflow
git status
git add file.py
git commit -m "Add perceptron implementation"
git push origin main#Step 3: Branching for experiments
git checkout -b experiment/new-optimizer
# ... make changes, commit ...
git checkout main
git merge experiment/new-optimizer#Step 4: Working with this course repo
git clone https://github.com/rohitg00/ai-engineering-from-scratch.git
cd ai-engineering-from-scratch
git checkout -b my-progress
# work through lessons, commit your code
git push origin my-progress#Use It
For this course, you need exactly these commands:
| Command | When |
|---|---|
git clone | Get the course repo |
git add + git commit | Save your work |
git push | Back it up to GitHub |
git checkout -b | Try something without breaking main |
git log --oneline | See what you've done |
That's it. You don't need rebase, cherry-pick, or submodules for this course.
#Exercises
- Clone this repo, create a branch called
my-progress, make a file, commit it, push it - Create a
.gitignorethat excludes model checkpoint files (.pt,.pth,.safetensors) - Look at the commit history of this repo with
git log --onelineand read how lessons were added
#Key Terms
| Term | What people say | What it actually means |
|---|---|---|
| Commit | "Saving" | A snapshot of your entire project at a point in time |
| Branch | "A copy" | A pointer to a commit that moves forward as you work |
| Merge | "Combining code" | Taking changes from one branch and applying them to another |
| Remote | "The cloud" | A copy of your repo hosted somewhere else (GitHub, GitLab) |
5 questions on this lesson
Answer each one and see straight away whether you were right and why. Your first answer to a question counts. You are not signed in, so this is practice and nothing is saved.
The text and code of this lesson are based on AI Engineering from Scratch by Rohit Ghumare, MIT licensed.