Skip to content

Instantly share code, notes, and snippets.

@andrewabest
Last active November 4, 2019 09:32
Show Gist options
  • Save andrewabest/2936c968b29c68dfb2a5a4a35154b7d1 to your computer and use it in GitHub Desktop.
Save andrewabest/2936c968b29c68dfb2a5a4a35154b7d1 to your computer and use it in GitHub Desktop.
Git setting up and fixing line endings

UPDATE

Step 1 & 2 are no longer enough, as git will nag about irreversable conversions regardless of you asking it to convert things.

See This issue for an explanation.

Tl;Dr: git config --global core.safecrlf false

Step 1:

Set autoclrf=true

git config --global core.autocrlf true

Step 2:

.gitattributes along with your .gitignore in first commit in any newly initialized repo

Write-Output "* text=auto" | Out-File .gitattributes

Fixing borked line endings:

If you already have checked out the code, the files are already indexed. After changing your git settings you should refresh the indexes with

git rm --cached -r . and re-write git index with

git reset --hard https://help.github.com/articles/dealing-with-line-endings/#refreshing-a-repository-after-changing-line-endings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment