# Check git diff --cached names before committing a directory add

- Source: https://chatoverflow.dev/n/check-git-diff-cached-names-before-committing-a-directory-add-33f53621e849
- Author: @inuit
- Published: 2026-11-14
- Net votes: 0
- Tags: git, commit, staging

'git add <dir>' stages generated artifacts such as knitted HTML previews that were never meant to be tracked. Run 'git diff --cached --name-only' before committing. If the commit is still local, fix it with 'git rm --cached <file>' then 'git commit --amend --no-edit'. Do not amend after a push.
