A repository that behaves differently on a Windows laptop than on a Linux CI runner is not a quirk. It is an unowned default, and it produces the review noise, phantom diffs and “works on my machine” incidents that eat a team’s time.
The fix is two files most projects either omit or copy from a template nobody reads. Set them deliberately, at the start, and a whole class of problems never appears: line endings stay consistent across a mixed Windows and Linux team, binary files stop showing up as unreadable diffs, and build artefacts and secrets-adjacent files never reach a commit in the first place. What follows is a baseline I use, with the reasoning, so you can adapt rather than cargo-cult it.
Line endings: normalise once, on commit
The recurring symptom is a pull request where every line shows as changed and nothing has actually changed. That is a line-ending conversion: someone on Windows checked out CRLF, their editor kept it, and the commit rewrote every line. Relying on each developer’s core.autocrlf setting does not solve this, because it lives in personal config and drifts between machines. The repository has to own the rule, and the mechanism for that is .gitattributes, which is committed and applies to everyone.
Free · 4 minutes
Is your engineering team shipping safely, or quietly accumulating risk?
Fourteen questions on how work gets from idea to production — cadence, testing, rollback, and the key-person risk in your delivery. Banded finding on screen, full sheet by email.
The line that does the work is * text=auto eol=lf. text=auto tells Git to store text files with LF in the repository and normalise on commit; eol=lf forces LF in the working tree too, on every platform, so a Windows checkout no longer silently swaps in CRLF. Setting eol takes precedence over whatever core.autocrlf a developer has locally, which is exactly what you want: one committed rule, no per-machine surprises. Where a tool genuinely needs CRLF — a Windows batch file, say — you override that single pattern.
# .gitattributes (repository root)
# Default: treat everything as text, store LF, check out LF everywhere.
* text=auto eol=lf
# Files that MUST keep CRLF to work on Windows.
*.bat text eol=crlf
*.cmd text eol=crlf
*.ps1 text eol=crlf
# Shell scripts must stay LF even if a Windows tool disagrees.
*.sh text eol=lf
Adding this to an existing repository does not retrofit history. New commits normalise, but files already stored with CRLF stay that way until touched. Force the one-off conversion with git add --renormalize . followed by a commit; that is your “the whole diff is line endings” commit, done once, deliberately, rather than leaking into every unrelated pull request thereafter.
Mark binaries so Git stops guessing
Git auto-detects binary content, but detection is heuristic and occasionally wrong — and when it is wrong, it tries to normalise line endings inside a PNG or a compiled artefact and corrupts it. Be explicit. The built-in binary macro is shorthand for -text -diff: do not touch line endings, do not attempt a textual diff. Apply it to images, archives, fonts, compiled objects and anything else that is not source.
# --- Binary assets: never munge, never diff as text ---
*.png binary
*.jpg binary
*.gif binary
*.ico binary
*.pdf binary
*.zip binary
*.gz binary
*.woff2 binary
*.so binary
*.dll binary
# --- Lockfiles: keep them, but collapse the noise ---
# Generated, huge, and no one reviews them line by line.
package-lock.json -diff linguist-generated
pnpm-lock.yaml -diff linguist-generated
poetry.lock -diff linguist-generated
uv.lock -diff linguist-generated
The lockfile block is the small refinement that pays off in review. -diff suppresses the inline diff so a regenerated lockfile does not bury a pull request under thousands of lines, and linguist-generated tells GitHub to collapse it by default and exclude it from language statistics. You still commit the lockfile — you should, it is what makes an install reproducible, the same discipline that makes a pinned developer toolchain worth having — you just stop pretending anyone reads its diff.
export-ignore: keep the tarball clean
If you ever ship a source archive — git archive, a release tarball, a dependency published from a repository — the consumer does not need your CI config, your test fixtures or your contributor docs. The export-ignore attribute strips those paths from the archive without removing them from the repository. It is purely cosmetic hygiene, but it is the difference between a lean release artefact and one that leaks your internal scaffolding.
# --- Strip from `git archive` / release tarballs ---
.gitattributes export-ignore
.gitignore export-ignore
.github/ export-ignore
tests/ export-ignore
docs/ export-ignore
*.md export-ignore
Note that export-ignore only affects git archive. It has no effect on a normal clone, and package managers that build from a full checkout ignore it — so treat it as tidiness for archives, not as a security control.
A layered .gitignore, not one sprawling file
Ignoring works best in three layers, each owned by whoever should own it. The repository .gitignore is committed and covers what every clone of this project generates. Your personal global ignore covers editor and OS cruft that is about your machine, not the project. And a nested .gitignore inside a generated directory keeps that concern local. Mixing all three into one committed file is how you end up with .DS_Store and someone’s .idea/ folder polluting a shared repository.
# .gitignore (repository root) — project-generated output
node_modules/
dist/
build/
.venv/
__pycache__/
*.pyc
coverage/
*.log
# Environment and secrets-adjacent files: never commit.
.env
.env.*
!.env.example
*.pem
*.key
# --- Personal, machine-level ignores (do NOT commit this) ---
# git config --global core.excludesfile ~/.gitignore_global
# .DS_Store
# Thumbs.db
# .idea/
# .vscode/
Two details earn their place. The !.env.example negation keeps a committed template while ignoring every real .env, so newcomers can copy the shape of the config without you ever committing a live secret. And keeping editor and OS files in your ~/.gitignore_global — wired up with core.excludesfile — means you are not asking every other contributor to carry your tooling choices. Large binary artefacts, model weights and datasets do not belong here at all; those want a separate provenance story, which is the argument for a proper bill of materials rather than a git repository straining under gigabytes it was never designed to hold.
Set it before the first real commit
None of this is difficult. It is unglamorous, it takes twenty minutes, and it is almost always skipped because the repository “works” without it — right up to the first cross-platform pull request that renders every file as changed, or the afternoon someone spends bisecting a corrupted binary. Committing a considered .gitattributes and a layered .gitignore on day one is the cheapest reliability decision in the whole delivery pipeline, and like agreeing the contract before writing the code, it is far cheaper set at the start than retrofitted after the habits have set. The best time to add these files was the first commit. The second best time is your next one.
Build and rescue work
Hands-on delivery of this kind is handled by Sixteen Pillars Studio.
Free interactive tool
Website compliance checklist
What your site has to do, based on what it actually does
Answer as much or as little as you like — the list builds as you go. Nothing is stored against your name and no email is required.
Everything that applies
Ordered by what to do first: legal requirements you can close quickly, then larger pieces of work, then what is expected rather than required. Not exhaustive, and not a legal audit.
Dated PDF, yours to keep or circulate.
Most technology problems are not technology problems. They are control problems.
The systems exist. The investment has been made. The question is whether leadership can understand, direct, evidence, and sustain what those systems produce. Find out where control exists — and where it only appears to.