Git Config
Shahab Movahhedi
2 min read
Docs
before proceeding, read these thoroughly:
- Stack Overflow: Git replacing LF with CRLF
- Stack Overflow: LF will be replaced by CRLF in git - What is that and is it important?
- GitHub Docs: Configuring Git to handle line endings
- The reference from Git itself
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
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 .
Also after changing the configs, It's usually a good idea to discard unwanted changes:
git rm --cached -r .
git reset --hard
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
tofalse
0
Subscribe to my newsletter
Read articles from Shahab Movahhedi directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Shahab Movahhedi
Shahab Movahhedi
Senior Developer, Designer, Technologist! ๐ฎ๐ท