Skip to content

Instantly share code, notes, and snippets.

@zbeekman
Created February 11, 2015 03:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save zbeekman/c3f2ef40ea176ba550fe to your computer and use it in GitHub Desktop.
Save zbeekman/c3f2ef40ea176ba550fe to your computer and use it in GitHub Desktop.
#!/bin/bash
sed -e 's/[ ]*$//' -e :a -e '/^\n*$/{$d;N;ba' -e '}' $1
@zbeekman
Copy link
Author

[filter "fix-eol-eof"]
        clean = fixup-eol-eof %f
        smudge = cat %f
        required = true

add that to your .gitconfig and put fixup-eol-eof somewhere on your PATH after making it executable to:

  1. Remove trailing tabs and spaces at the end of each line
  2. Remove extra black lines at the end of a file
    before each commit. Then set the gitattributes of whatever files you’d like this applied to, to filter=fix-eol-eof

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