DCubes
Git module

Lesson 4

gitignore

Ignore venvs, data, env files, and other noise DE repos should never track.

beginner25 minRun on your machine

What you will be able to do

  • Write a .gitignore for a data project
  • Confirm ignored files do not appear as untracked
  • Know that already-tracked files need git rm --cached

Why this matters for data work

One accidental commit of .env or a 2 GB extract is a bad day. .gitignore is policy as code.

Concepts

  • Patterns: .venv/, data/raw/, .env, *.pyc
  • Comments with #
  • Ignore only works for untracked files

Practice on your machine

cd ~/dcubes/git-lab/init-demo
cat > .gitignore << 'EOF'
.venv/
__pycache__/
.env
data/raw/
data/out/
*.log
.ipynb_checkpoints/
EOF
mkdir -p data/raw
echo "secret=nope" > .env
echo "big" > data/raw/dump.csv
git status
git add .gitignore
git commit -m "Add DE-oriented gitignore"
git status

.env and data/raw/dump.csv should not list as untracked.

What you should see

  • Only intended files in status after ignore rules.
  • A commit that adds .gitignore.

Common mistakes

  • Committing then ignoring — still tracked; git rm --cached file then commit.
  • Ignoring data/ when you meant only raw — keep tiny fixtures if you need them.

Next

clone and navigate