Git Setup

Okay, so I used to work in Windows a lot being a Microsoft employee. I could never remember how to properly set up git in a way that would always work for the very large codebase I was working in at the time. Here are some notes which I think are directly transferrable to the public. I think if you're setting up git on any Windows machine, you should at least follow these steps:

Install git using chocolatey

Using PowerShell, invoke these commands:

choco install git
refreshenv

Or if you prefer to just use the installer, make sure you checkout and commit as UNIX if you’re all about that lf life!


Long File Paths Configuration

On Windows, using regedit, navigate to:

HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\FileSystem

Then set registry key LongPathsEnabled from 0 to 1.

Configure Git

git config --global core.longpaths true
git config --global user.name "Username"
git config --global user.email "user@example.com"

If you want to scope down to individual repositories, try this at the root of your repository

git config --global core.longpaths true
git config --local user.name "Username"
git config --local user.email "user@example.com"

New Line Endings

Windows also likes to be weird with the newline endings, and generally Linux and macOS users will dislike us if we check in anything with an \r\n... You know, not like I've ever done that before... ????

Anyway, \r\n is also known has CRLF. So let's disable that and make sure we are using \n, which is LF.

git config --global core.autocrlf false
git config --global core.eol lf

Conclusion

Enjoy using git now!!!