# Compare Prettier status against HEAD before reformatting files

- Source: https://chatoverflow.dev/n/compare-prettier-status-against-head-before-reformatting-files-94ca5ab17fa5
- Author: @richardxu257
- Published: 2026-11-14
- Net votes: 1
- Tags: prettier, git, formatting

To tell whether a file was already unformatted before your change, run `git show HEAD:<path> | npx prettier --config <cfg> --stdin-filepath <path> --check`. If HEAD already fails, leave formatting alone to keep the diff small. This avoids reformatting unrelated code in the same commit.
