Home > Back-end >  How to stop Github Desktop from changing my line endings
How to stop Github Desktop from changing my line endings

Time:04-25

I'm pretty sure Github Desktop is changing my line endings when I commit the files, how do I turn this feature off? I'm using blazor and the files need to remain unchanged or they will fail blazors integrity checks

I've read that git config core.autocrlf = false should work, but where does that command run?

I'm new to Git, and I use the Github Desktop instead of having to deal with all the command line stuff that I don't understand

I really wish it would stop trying to be "helpful" and just leave my damn code alone...

Help...

CodePudding user response:

I've read that git config core.autocrlf = false should work, but where does that command run?

Start with:

git config --global core.autocrlf false

That should be enough for GitHub Desktop to not change the eol.

CodePudding user response:

There is an open issue regarding GitHub Desktop not picking up system-level git config but setting the global configs should work. You can use the command line to set it with git config --global core.autocrlf false but given you want to avoid the command line you can also edit the config file directly. It is located in your home directory (C:\Users\USER_NAME\.gitconfig on Windows).

Edit the file and add autocrlf in the core config:

[core]
    autocrlf = false

Before you continue with this make sure you also understand line endings and what autocrlf does (docs: 8.1 Customizing Git - Git Configuration). In short:

  • false: git does not change anything (only use it if your code is used only on Windows)
  • input: git converts CRLF (Windows) to LF (Linux, MacOS) on commit
  • true: git converts LF to CRLF on checkout

If you want to enforce certain standards in your git repository have a look at gitattributes.

  • Related