Git Config

ยท

2 min read

Docs

before proceeding, read these thoroughly:

Where is the global Git Config file?

  • Windows : C:/Users/<USER_NAME>/.gitconfig
  • Unix: ~/.gitconfig

Changing Configs

To list all configs:

git config --global --list

To unset a config:

git config --global --unset core.autocrlf

If there are multiple records with the same key,

git config --global --unset-all core.autocrlf

To replace values of the config:

git config --global --replace-all core.autocrlf "New Value"

To remove an entire section:

git config --global --remove-section core

Or to edit the config file manually:

git config --global --edit

Source

EOL in Git

There are 3 configs related to EOL:

  • core.eol
  • core.autocrlf
  • core.safecrlf

If the EOLs at all messed up, you can also use:

git add --renormalize .

Source

Also after changing the configs, It's usually a good idea to discard unwanted changes:

git rm --cached -r .
git reset --hard

Source

What I Figured Out

At the end (until 2024/02/24), I figured, for me, it's best to:

  • Remove core.eol
  • Remove core.safecrlf
  • Set core.autocrlf to false
ย