Skip to content

Instantly share code, notes, and snippets.

@svdmitrij
Last active November 14, 2015 10:18
Show Gist options
  • Save svdmitrij/b2f5459a3f42f3f600e1 to your computer and use it in GitHub Desktop.
Save svdmitrij/b2f5459a3f42f3f600e1 to your computer and use it in GitHub Desktop.
Fix line endings problem when work on windows and linux (when lot of messages The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in...)
#!/usr/bin/env bash
# https://help.github.com/articles/dealing-with-line-endings/#refreshing-a-repository-after-changing-line-endings
git add . -u
git commit -m "Saving files before refreshing line endings"
git rm --cached -r .
git reset --hard
git add .
git commit -m "Normalize all the line endings"
# Now you can git reset --hard HEAD~2 if have two last commits or git reset --hard HEAD~1 if one.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment