Add .gitattributes to fix line endings for Windows devcontainer users#20
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a .gitattributes file to enforce consistent line endings across platforms, specifically to prevent Windows Git's default CRLF conversion from breaking shell scripts that run in Linux devcontainers. The fix addresses the immediate issue where auth_init.sh failed to execute in a Windows devcontainer due to incorrect line endings.
Key Changes:
- Added
.gitattributeswithtext=autofor automatic text file detection and LF normalization - Configured LF line endings for shell scripts, Python files, Dockerfiles, and configuration files used in Linux containers
- Configured CRLF line endings for Windows-specific scripts (
.bat,.cmd,.ps1) - Marked binary file types appropriately
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| # Shell scripts must use LF (they run in Linux containers/devcontainers) | ||
| *.sh text eol=lf | ||
| entrypoint.sh text eol=lf |
There was a problem hiding this comment.
The pattern 'entrypoint.sh' is redundant since line 5 already covers all '*.sh' files, which includes 'entrypoint.sh'. This redundant rule should be removed to keep the configuration cleaner and avoid confusion.
|
LGTM, I've had to do similar before: |
I was testing out our repo on Windows in a devcontainer and azd up failed with /bin/sh: 1: ./infra/auth_init.sh: not found, even though the file existed.
Windows Git defaults to converting line endings to CRLF (users can disable this, some don't, like me), which breaks shell scripts in the devcontainer.
Added a .gitattributes file to enforce correct line endings per-repo, so it works for everyone automatically.