Skip to content

Instantly share code, notes, and snippets.

@berinle
Last active August 8, 2026 17:45
Show Gist options
  • Select an option

  • Save berinle/e2aef32865d97cc30ca66c687704586a to your computer and use it in GitHub Desktop.

Select an option

Save berinle/e2aef32865d97cc30ca66c687704586a to your computer and use it in GitHub Desktop.
generic git attributes when working between windows and linux
# ---------------------------------------------------------------------------
# Line-ending normalization for Windows <-> Linux/macOS work.
#
# Rule of thumb: everything is stored as LF in the repository. Files that are
# only ever consumed by Linux (shell scripts, Dockerfiles, configs baked into
# images) are also checked out as LF on Windows, because CRLF breaks them.
# ---------------------------------------------------------------------------
# Default: let Git decide what is text, normalize to LF in the repo, and check
# out as LF everywhere — including Windows. Without the explicit `eol=lf`, Git
# falls back to core.eol=native and rewrites text files as CRLF on Windows,
# which produces "LF will be replaced by CRLF" warnings on every `git add`.
* text=auto eol=lf
# ---------------------------------------------------------------------------
# Force LF on checkout — these run inside Linux containers / on the server.
# A CRLF here produces "bad interpreter: /bin/bash^M" or a broken image build.
# Redundant now that the default above is eol=lf, but kept explicit so these
# stay LF even if someone loosens the default rule.
# ---------------------------------------------------------------------------
*.sh text eol=lf
*.bash text eol=lf
*.zsh text eol=lf
*.py text eol=lf
*.pl text eol=lf
*.rb text eol=lf
Dockerfile text eol=lf
Dockerfile.* text eol=lf
*.dockerfile text eol=lf
.dockerignore text eol=lf
docker-compose*.yml text eol=lf
docker-compose*.yaml text eol=lf
Makefile text eol=lf
makefile text eol=lf
*.mk text eol=lf
*.yml text eol=lf
*.yaml text eol=lf
*.json text eol=lf
*.conf text eol=lf
*.cfg text eol=lf
*.ini text eol=lf
*.properties text eol=lf
*.toml text eol=lf
*.env text eol=lf
.env.* text eol=lf
# Dotfiles and extensionless scripts that live in a Linux runtime
.gitattributes text eol=lf
.gitignore text eol=lf
.editorconfig text eol=lf
*.service text eol=lf
*.timer text eol=lf
# ---------------------------------------------------------------------------
# Force CRLF on checkout — Windows-only tooling chokes on LF.
# ---------------------------------------------------------------------------
*.bat text eol=crlf
*.cmd text eol=crlf
*.ps1 text eol=crlf
*.psm1 text eol=crlf
*.sln text eol=crlf
*.vcxproj text eol=crlf
# ---------------------------------------------------------------------------
# Text files that inherit eol=lf from the default rule above, declared
# explicitly so Git never guesses wrong about text-vs-binary or diff driver.
# ---------------------------------------------------------------------------
*.md text diff=markdown
*.txt text
*.html text diff=html
*.htm text diff=html
*.css text diff=css
*.scss text diff=css
*.js text
*.mjs text
*.cjs text
*.ts text
*.jsx text
*.tsx text
*.xml text
*.svg text
*.sql text
*.csv text
*.tsv text
# ---------------------------------------------------------------------------
# Binary — never normalize, never diff, never merge line-by-line.
# ---------------------------------------------------------------------------
*.png binary
*.jpg binary
*.jpeg binary
*.gif binary
*.ico binary
*.webp binary
*.avif binary
*.bmp binary
*.tif binary
*.tiff binary
*.pdf binary
*.woff binary
*.woff2 binary
*.ttf binary
*.otf binary
*.eot binary
*.mp3 binary
*.mp4 binary
*.mov binary
*.webm binary
*.ogg binary
*.wav binary
*.zip binary
*.gz binary
*.tgz binary
*.bz2 binary
*.xz binary
*.7z binary
*.rar binary
*.jar binary
*.war binary
*.ear binary
*.class binary
*.so binary
*.dylib binary
*.dll binary
*.exe binary
*.bin binary
*.pyc binary
*.db binary
*.sqlite binary
*.sqlite3 binary
# ---------------------------------------------------------------------------
# Generated / vendored — keep them out of diffs and language stats on GitHub.
# ---------------------------------------------------------------------------
package-lock.json -diff linguist-generated
yarn.lock -diff linguist-generated
pnpm-lock.yaml -diff linguist-generated
*.min.js -diff linguist-generated
*.min.css -diff linguist-generated
*.map -diff linguist-generated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment