Git for AI Projects
git init, .gitignore for data/models, committing notebooks, DVC for data versioning.
Git for AI Projects is a free Learn AI with Python lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Learn AI with Python learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Git in AI Projects
Git tracks changes to your code so you can collaborate, revert mistakes, and review history. But AI projects add a twist: huge data files and binary models do not belong in Git.
This lesson covers a sensible .gitignore and using DVC for data versioning.
What Git Tracks Well
Git shines with text: source code, configs, notebooks (with cleared outputs), and docs. It stores efficient diffs of text files.
It handles large binaries poorly — every version is stored in full, bloating the repository forever.
Why Not Commit Data and Models
Committing a 2 GB dataset or a 500 MB model:
- Bloats the repo, slowing every clone
- Cannot be diffed meaningfully
- Stays in history forever, even after deletion
Solution: ignore them in Git and version them with a dedicated tool.
The .gitignore File
.gitignore lists patterns Git should not track. Create it at the project root. Each line is a glob pattern.
# .gitignore
*.pkl
*.joblib
*.h5
data/raw/*
data/processed/*
models/*
__pycache__/
*.pyc
.ipynb_checkpoints/
.envIgnoring Model and Cache Files
Common AI ignore patterns:
*.pkl,*.joblib,*.h5— serialized models__pycache__/,*.pyc— Python bytecode.ipynb_checkpoints/— Jupyter autosaves.env— secrets and API keys (never commit these!)
Keeping Empty Folders with .gitkeep
Git ignores empty directories. To keep data/raw/ in the repo structure while ignoring its contents, add an empty .gitkeep file and a negation.
# .gitignore
data/raw/*
!data/raw/.gitkeepIntroducing DVC
DVC (Data Version Control) versions large data and models alongside Git. Git tracks small .dvc pointer files; the actual data lives in remote storage (S3, GCS, etc.).
You get reproducible data versions without bloating the Git repo.
dvc init
Initialize DVC inside an existing Git repo. It creates a .dvc/ directory and config that you commit to Git.
# in your git repo
dvc init
git add .dvc .gitignore
git commit -m "Initialize DVC"dvc add — Tracking Data
dvc add starts tracking a file or folder. DVC moves the data to its cache and creates a small .dvc pointer file. You commit the pointer to Git, not the data.
dvc add data/raw/dataset.csv
# creates data/raw/dataset.csv.dvc
git add data/raw/dataset.csv.dvc data/raw/.gitignore
git commit -m "Track dataset with DVC"dvc push and dvc pull
Configure a remote, then dvc push uploads data to it and dvc pull downloads the version matching the current Git commit. This is how teammates share data.
dvc remote add -d storage s3://my-bucket/dvcstore
dvc push # upload data to the remote
# teammate after git clone + git checkout:
dvc pull # fetch the matching data versionThe Team Workflow
The Git + DVC loop ties code and data versions together:
git pullto get the latest code and.dvcpointersdvc pullto fetch the matching data and models- Work, then
dvc add+git commit+dvc push
Checking out an old commit and running dvc pull reproduces that exact state.
Quick Check: Large Files
Your project has a 1 GB training dataset and a 300 MB model file.
Recap: Git for AI Projects
You learned AI-specific version control:
- Git for text (code, configs, notebooks); not for big binaries
- A
.gitignorefor*.pkl,data/raw/*,__pycache__,.env .gitkeepto preserve empty folders- DVC:
dvc init,dvc add,dvc push/pullto version data and models - The Git + DVC workflow keeps code and data in sync
Next: making experiments reproducible.
Frequently asked questions
Is the “Git for AI Projects” lesson free?
Yes — the full text of “Git for AI Projects” is free to read here on the web, and the Learn AI with Python course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Learn AI with Python course, upgrade to CoddyKit PRO.
What will I learn in “Git for AI Projects”?
git init, .gitignore for data/models, committing notebooks, DVC for data versioning. You practise Learn AI with Python with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Learn AI with Python?
No prior experience is required. Learn AI with Python on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Git for AI Projects” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Learn AI with Python lesson?
Yes. Every Learn AI with Python lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.