Skip to content

Latest commit

 

History

History
65 lines (50 loc) · 2.04 KB

File metadata and controls

65 lines (50 loc) · 2.04 KB
title Accidental __pycache__ artifacts committed to a data repository
domain development
tags
git
pycache
gitignore
cleanup
status published
evidence_level E2
created 2026-08-11 00:00:00 UTC
updated 2026-08-11 00:00:00 UTC

Accidental pycache artifacts committed to a data repository

Problem

A pull request intended to change CSV data rows also shipped __pycache__/csv_to_json.cpython-314.pyc (and similar bytecode files). The reviewer flagged it as a MEDIUM issue: repository bloat, non-deterministic artifacts, and potential noise that obscures the real diff. The branch could not merge until the artifacts were removed.

Root Cause

The contributor used git add -A inside a worktree that contained Python __pycache__ directories generated by an earlier local run of a validation script. There was no .gitignore, so bytecode files were staged alongside the intended changes.

Solution

Remove the staged artifacts and prevent recurrence with a .gitignore.

Step 1

Remove the artifacts from the index and disk:

git rm --cached -r __pycache__ 2>/dev/null || true
git rm -r --cached '*.pyc' 2>/dev/null || true
rm -rf __pycache__

Step 2

Add a .gitignore covering Python bytecode:

__pycache__/
*.pyc

Step 3

Re-stage only the intended files instead of the whole directory:

git add references/offers/sdks.csv
git commit -m "fix: remove committed pycache artifacts"

Step 4

Verify the diff contains only intended changes: git status --short and git diff --name-only should list nothing under __pycache__.

Verification

  1. git ls-files | grep -c pyc returns 0.
  2. git status --short shows only intended files.
  3. CI passes on the cleaned branch.

Notes

Never git add -A in worktrees where scripts generated artifact directories. A .gitignore with __pycache__/ and *.pyc is the cheapest insurance against reviewer-triggering noise, and stage specific files rather than whole directories.