Skip to content

Instantly share code, notes, and snippets.

@rogeriopradoj
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rogeriopradoj/f87666af7d9ab8b98e21 to your computer and use it in GitHub Desktop.
Save rogeriopradoj/f87666af7d9ab8b98e21 to your computer and use it in GitHub Desktop.
consertar line endings git windows
# Auto detect text files and perform LF normalization
* text eol=lf
# Faz com que arquivos gerados pelo SQL Server sejam tratados como texto
*.DTS sql diff
*.JOB sql diff
*.PRC sql diff
*.TAB sql diff
*.TRG sql diff
*.VIW sql diff

Refreshing a repository after changing line endings

After you've set the core.autocrlf option and committed a .gitattributes file, you may find that Git wants to commit files that you have not modified. At this point, Git is eager to change the line endings of every file for you.

The best way to automatically configure your repository's line endings is to first backup your files with Git, delete every file in your repository (except the .git directory), and then restore the files all at once.

Save your current files in Git, so that none of your work is lost.

git add . -u git commit -m "Saving files before refreshing line endings" Remove every file from Git's index.

git rm --cached -r . Rewrite the Git index to pick up all the new line endings.

git reset --hard Add all your changed files back, and prepare them for a commit. This is your chance to inspect which files, if any, were unchanged.

git add .

It is perfectly safe to see a lot of messages here that read

"warning: CRLF will be replaced by LF in file."

Commit the changes to your repository.

git commit -m "Normalize all the line endings" Thanks to Charles Bailey's post on Stack Overflow for the basis to this solution.

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