5

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...

Michael
  • 101
  • 2
  • 5
  • _"but where does that command run"_ - in the terminal or command prompt. – evolutionxbox Apr 25 '22 at 07:09
  • really? that simple. I get command not found, the Github Desktop is a PWA so it must not have brought the exe with it – Michael Apr 25 '22 at 07:16
  • Do you have "git bash" installed? If so, consider using that instead of command prompt. – evolutionxbox Apr 25 '22 at 07:17
  • I was hoping to avoid learning git, that's why I went for the GUI, problem is that it tries to be helpful and hides behind layers of magic. I'll check it out, thankyou – Michael Apr 25 '22 at 07:21
  • 2
    Never avoid learning git. You don't need to learn the commands, but definitely learn the concepts it uses. – evolutionxbox Apr 25 '22 at 07:24

2 Answers2

9

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.

Simon
  • 129
  • 1
  • 1
  • 4
3

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.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250