Skip to content

Prevent Git from normalizing line endings in *.min.css files#10745

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/fix-bootstrap-css-line-endings
Draft

Prevent Git from normalizing line endings in *.min.css files#10745
Copilot wants to merge 2 commits intomainfrom
copilot/fix-bootstrap-css-line-endings

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 24, 2026

Local VS deployment runs CSS bundling that strips CRLF from minified CSS files (e.g. bootstrap.min.css), causing spurious diffs on Windows with core.autocrlf=true.

  • Add *.min.css -text to .gitattributes directly after the *.css text=auto rule — later rules win in .gitattributes, so this correctly overrides line-ending normalization for minified CSS only
Original prompt

This section details on the original issue you should resolve

<issue_title>Deploying NuGetGallery locally changes bootstrap.min.css line endings from CRLF to LF</issue_title>
<issue_description>Deploying the NuGetGallery locally from VS results in a bootstrap.min.css file modification even if the file hasn't been changed. This is somewhat annoying as I have to constantly work around the modified css file when staging changes.

PS C:\git\NuGetGallery> git config core.autocrlf
true

On checkout we have CRLF line endings in the working directory:

PS C:\git\NuGetGallery> git ls-files --eol
...
i/lf    w/crlf  attr/text=auto          src/NuGetGallery/Content/gallery/css/bootstrap.min.css
...

After deploying the line endings are now LF:

PS C:\git\NuGetGallery> git ls-files --eol
...
i/lf    w/lf    attr/text=auto          src/NuGetGallery/Content/gallery/css/bootstrap.min.css
...

Examining the diff:

PS C:\git\NuGetGallery> git diff HEAD --no-ext-diff --patch-with-raw -z --no-color -- .\src\NuGetGallery\Content\gallery\css\bootstrap.min.css
warning: in the working copy of 'src/NuGetGallery/Content/gallery/css/bootstrap.min.css', LF will be replaced by CRLF the next time Git touches it

I suspect the reason the line endings are changing has something to do with style rendering that bundles the minified css files:

@Styles.Render("~/Content/gallery/css/site.min.css")
@Styles.Render("~/Content/gallery/css/bootstrap.min.css")

One solution that I think would work is to prevent git from modifying line endings for the bootstrap.min.cs file by adding this line to .gitattributes:

*.min.css -text
```</issue_description>

<agent_instructions> Implement the propose solution or come up with a better solution
</agent_instructions>

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Fix bootstrap.min.css line endings for local deploy Prevent Git from normalizing line endings in *.min.css files Mar 24, 2026
Copilot AI requested a review from chabiss March 24, 2026 00:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deploying NuGetGallery locally changes bootstrap.min.css line endings from CRLF to LF

2 participants