Search This Blog

Git end-of-line conversion settings

Enable end-of-line conversion

git config --global core.autocrlf input
  • Make sure your IDE (Text) Editors are unix/dos EOL aware.
  • Global git config:
    git config --global core.autocrlf input
    git config --global core.safecrlf true
  • Create .gitattributes file at the root the git repository, and add configuration like below:
    *       text=auto
    *.java      text
    *.xml       text
    *.sh        text eol=lf
    *.cmd       text eol=crlf
    *.bat       text eol=crlf
    *.jpg       -text
    *.png       -text
    *.gif       -text
  • Normalise the EOL for all the files in the repository:
    git add --renormalize .
    git status        # Show files that will be normalized
    git commit -m "Introduce end-of-line normalization"



Disable end-of-line conversion

git config --global core.autocrlf false



See also

No comments:

Post a Comment