Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Auto-detect text files and normalize them to LF in the working tree on
# checkout, regardless of each contributor's global git config.
* text=auto eol=lf

# Shell scripts must use LF line endings — a CRLF on the shebang line makes
# the kernel look for "/bin/bash\r" and fail with "bad interpreter".
*.sh text eol=lf
Comment on lines +5 to +7

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional enhancement: Consider prepending a * text=auto rule before the *.sh line. It's the standard first line in .gitattributes — it tells git to auto-detect text files and normalize their line endings on commit. Combined with the explicit *.sh text eol=lf override, this gives blanket protection to all text files (YAML, R, Quarto, etc.) while still guaranteeing LF in working-tree shell scripts.

Suggested change
# Shell scripts must use LF line endings — a CRLF on the shebang line makes
# the kernel look for "/bin/bash\r" and fail with "bad interpreter".
*.sh text eol=lf
# Auto detect text files and perform LF normalization
* text=auto
# Shell scripts must use LF line endings — a CRLF on the shebang line makes
# the kernel look for "/bin/bash\r" and fail with "bad interpreter".
*.sh text eol=lf

Not blocking — the current rule already solves the stated problem. The only downside to text=auto is it may trigger renormalization of other tracked files on first checkout for contributors; run git add --renormalize . locally to see if anything would change before merging.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adopted, with one tweak: used * text=auto eol=lf rather than bare * text=auto, so LF is actually forced in the working tree on checkout (bare text=auto leaves native EOL, i.e. CRLF on Windows) — this matches the repo owner's global gitattributes. Verified zero renormalization churn: git grep -lI $'\r' origin/main returns nothing and git add --renormalize . stages only .gitattributes. Worth noting this repo's working tree already has 19 CRLF files including 6 Python/R scripts whose shebangs would break the same way the .sh did, so the blanket rule is the better fix here.

Loading