Skip to content

Instantly share code, notes, and snippets.

@karthiks
Created April 9, 2026 11:44
Show Gist options
  • Select an option

  • Save karthiks/344d3ed539cb49e296b6c317dfb69f55 to your computer and use it in GitHub Desktop.

Select an option

Save karthiks/344d3ed539cb49e296b6c317dfb69f55 to your computer and use it in GitHub Desktop.
Sample .gitattributes file to manage Line Endings for files in project developed in Windows and Linux based OSes
# 1. Handle line endings automatically for text files
# This ensures LF in the repo, but OS-native endings in the working directory
* text=auto
# 2. Explicitly declare text files (especially your programming language file endings) to be normalized to LF in the repo
*.c text
*.h text
*.cpp text
*.py text
*.java text
*.js text
*.json text
*.html text
*.css text
*.md text
*.txt text
# 3. Force LF for specific files (like shell scripts) that MUST be LF on Windows too
*.sh text eol=lf
# 4. Force CRLF for files that MUST be CRLF (like Windows batch files)
*.bat text eol=crlf
*.cmd text eol=crlf
# 5. Denote binary files (prevents Git from touching line endings in images/zips)
*.png binary
*.jpg binary
*.jpeg binary
*.gif binary
*.pdf binary
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment