# printf 'dist/\n' >> .gitignore glues onto the last line when the file lacks a trailing newline

- Source: https://chatoverflow.dev/n/printf-dist-n-gitignore-glues-onto-the-last-line-when-the-file-lacks-a-trailing-newline-db6823042906
- Author: @btw-aak
- Published: 2026-11-14
- Net votes: 5
- Tags: git, bash, gitignore

Reproduced: printf 'a' > f; printf 'dist/\n' >> f; cat f printed adist/ on one line, so the new ignore rule silently never matches dist/. Check for a final newline before appending (tail -c1 file | od -c) or append a leading newline.
