๐Ÿงฐ Why Git for Data Projects?

Professional data work needs history, reproducibility, and clean delivery.

The problem Git solves

Without Git, projects turn into folders like final.csv, final_v2.ipynb, and final_REALLY_FINAL.ipynb. Git gives you a timeline of changes, so every experiment has context.

What Git tracks

  • Code - notebooks, Python scripts, SQL files, and configs.
  • Decisions - commit messages explain what changed and why.
  • Project state - you can return to an older working version.
Rule: Git is for source files and small docs. Large raw data, secrets, model binaries, and private files should not be committed.

Git vs GitHub

Git is the version-control tool on your machine. GitHub is a hosting and collaboration platform for Git repositories.

๐ŸŽฏ TASKAudit a Project Folder
Create a quick audit checklist for a data project. Mark which files should be tracked by Git and which should be ignored.
Starter code:
python
files = [ "analysis.ipynb", "src/clean_data.py", "README.md", "data/raw/customers.csv", ".env", "model.pkl" ] # Print each file with one of: # TRACK, IGNORE, or REVIEW for file in files: print(file, "->", "???")

โš™๏ธ Install & Configure Git

Set your identity and confirm Git is ready.

Essential commands

bash
git --version git config --global user.name "Your Name" git config --global user.email "you@example.com" git config --global init.defaultBranch main git config --list

Why identity matters

Every commit stores an author name and email. This is how GitHub connects your local commits to your profile.

Tip: Use the same email address connected to your GitHub account, or use GitHub's private noreply email if you prefer privacy.
๐ŸŽฏ TASKGenerate Your Git Setup Checklist
Create a command checklist for configuring Git on a new machine.
Starter code:
python
name = "Your Name" email = "you@example.com" commands = [ # add the setup commands here ] for command in commands: print(command)

๐Ÿ“ฆ Repositories & Commits

A repository is the tracked project; a commit is a saved checkpoint.

Core workflow

bash
git init git status git add README.md notebooks/analysis.ipynb src/clean.py git commit -m "Add first analysis workflow"

Good commit messages

A useful commit message says what changed in a specific, readable way. Use verbs like Add, Fix, Refactor, Document, and Update.

๐ŸŽฏ TASKBuild a Commit Plan
Given a list of project changes, group them into focused commits with clear messages.
Starter code:
python
changes = [ "clean missing values", "add revenue chart", "write README", "fix typo in notebook", "save raw dataset" ] # Create focused commit messages. commit_messages = [] for message in commit_messages: print("-", message)

๐ŸŒฟ Branches & Safe Experiments

Branches let you experiment without damaging the main project.

Common branch workflow

bash
git switch -c feature/churn-model git status git add . git commit -m "Add churn model baseline" git switch main git merge feature/churn-model

Naming branches

Use clear names such as feature/sales-dashboard, fix/readme-setup, or analysis/customer-churn-eda.

๐ŸŽฏ TASKCreate Branch Names
Convert project tasks into clean branch names.
Starter code:
python
tasks = [ "Add EDA notebook", "Fix README instructions", "Build sales dashboard", "Try random forest model" ] # Convert each task into a branch name. for task in tasks: print(task, "->", "???")

โ˜๏ธ GitHub Remote Workflow

Push your local repository to GitHub and collaborate safely.

Local to GitHub

bash
git remote add origin https://github.com/username/project-name.git git branch -M main git push -u origin main

Daily sync commands

bash
git pull git status git add . git commit -m "Update analysis" git push
Professional habit: Pull before starting work, commit focused changes, and push when the project is in a meaningful state.
๐ŸŽฏ TASKGenerate Remote Commands
Generate the first-push commands for a GitHub repository.
Starter code:
python
username = "yourusername" repo = "sales-dashboard" # Print the commands needed to connect and push. commands = [] for command in commands: print(command)

๐Ÿ›ก๏ธ .gitignore & Data Safety

Protect private files and keep repositories lightweight.

Files you usually ignore

  • .env files with API keys.
  • Large raw datasets and exports.
  • Python cache folders like __pycache__/.
  • Model binaries like *.pkl unless deliberately versioned elsewhere.
gitignore
.env __pycache__/ *.pyc data/raw/ data/private/ models/*.pkl .ipynb_checkpoints/
๐ŸŽฏ TASKGenerate a Data Project .gitignore
Create a .gitignore template for a professional data analysis repository.
Starter code:
python
ignore_rules = [ # add rules here ] print("\\n".join(ignore_rules))

๐Ÿ—‚๏ธ Project Folder Structure

A clear structure helps other people trust and rerun your work.

Recommended layout

text
project-name/ README.md requirements.txt notebooks/ 01_eda.ipynb 02_modeling.ipynb src/ clean_data.py features.py data/ raw/ processed/ reports/ figures/

This layout separates exploration, reusable code, data, and final reports. It also makes the repository easier to review.

๐ŸŽฏ TASKCreate a Project Tree
Generate a clean folder tree for a customer churn project.
Starter code:
python
project = "customer-churn-analysis" folders = [ # add folders here ] print(project + "/") for folder in folders: print(" " + folder)

๐Ÿ“Œ requirements.txt & Environments

Reproducibility means someone else can install the same dependencies.

Two common files

bash
pip freeze > requirements.txt pip install -r requirements.txt

Better manual requirements for portfolio projects

text
pandas numpy matplotlib seaborn scikit-learn jupyter

A manually curated requirements file is often cleaner than freezing every package from a large environment.

๐ŸŽฏ TASKBuild Requirements from Imports
Given imports from a notebook, generate a minimal requirements list.
Starter code:
python
imports = ["pandas", "numpy", "matplotlib.pyplot", "sklearn", "sqlite3"] # Map imports to package names. requirements = [] for package in requirements: print(package)

๐Ÿ“ README for Data Projects

Your README is the front door to your portfolio project.

README sections that matter

  • Project goal and business question.
  • Dataset source and limitations.
  • Method summary.
  • Key findings with visuals.
  • How to run the project.
markdown
# Customer Churn Analysis ## Goal Predict which customers are likely to churn and identify retention opportunities. ## Key Findings 1. Month-to-month contracts have the highest churn risk. 2. Higher monthly charges are associated with higher churn. ## How to Run pip install -r requirements.txt
๐ŸŽฏ TASKGenerate a README Draft
Create a README template for a sales dashboard portfolio project.
Starter code:
python
project = "Sales Dashboard" goal = "Analyze revenue trends and product performance" findings = [ # add findings here ] # Build markdown text. readme = "" print(readme)

๐Ÿšข Portfolio Release Checklist

Before publishing, review the project like a hiring manager would.

Release criteria

  • Notebook runs top-to-bottom.
  • README explains the business question and findings.
  • No secrets or private data are committed.
  • Charts are readable and decision-focused.
  • Environment and data instructions are clear.

Final Git flow

bash
git status git add README.md requirements.txt notebooks/ src/ git commit -m "Prepare portfolio release" git push
๐ŸŽฏ TASKScore Your Project Readiness
Build a small scoring checklist. A project is portfolio-ready when it scores at least 5 out of 6.
Starter code:
python
checks = { "README explains goal": True, "Notebook runs top-to-bottom": False, "No secrets committed": True, "requirements.txt exists": True, "5+ insights included": False, "charts are readable": True } # Calculate score and print readiness decision.