If you're experiencing automatic changes to files after committing (especially whitespace changes), here are the most common causes and solutions:
- Format on Save:
"editor.formatOnSave": true - Trim Trailing Whitespace:
"files.trimTrailingWhitespace": true - Auto Whitespace:
"editor.trimAutoWhitespace": true
- Pre-commit hooks running formatters
- Post-commit hooks
- Check
.git/hooks/directory
- Markdown formatters
- Prettier
- Auto-formatting extensions
.editorconfigfiles with trim settings- Language-specific formatting rules
{
"editor.formatOnSave": false,
"editor.trimAutoWhitespace": false,
"files.trimTrailingWhitespace": false,
"[markdown]": {
"editor.formatOnSave": false,
"editor.trimAutoWhitespace": false,
"files.trimTrailingWhitespace": false
}
}- Disables trailing whitespace trimming for Markdown files
- Maintains consistent behavior across editors
- Use
./lint.shfor intentional formatting - Use
./format-modified.shfor changed files only
- Make a small change to README.md
- Save the file
- Commit the change
- Check if automatic changes still occur
If problems persist, check:
- Global VS Code settings (
Ctrl+Shift+P> "Preferences: Open Settings (JSON)") - Installed VS Code extensions
- Git configuration for hooks