After installing Git, you may want to do some basic configuration so you can have a proper versioning history and collaborate with others in a shared repository.
First thing, you want to do before anything is to set your name and email.
You can open Git Bash on Windows or Terminal for macOS.
Replacing the First, Last and email address with your own, type the following:
git config --global user.name "First Last" git config --global user.email email@example.com
This will be useful when you collaborate with others to see who has made what changes in the repository.
The next one, you want to set how the end of the line is treated in Git. This is often overlooked by many and usually does not pose any issues if everyone uses the same system or you just use Git by yourself. However if you check in and out your code using different platforms, it can cause an issue.
A bit of explanation with the end of the line for each OS here. On Windows an end of line consists of two characters \r\n which is a carriage return followed by a line feed. macOS on the other hand, only uses \n (line feed) and no carriage return. As such, whenever someone checks code in or out, Git needs to know how to treat the line ends so everyone will have consistent experience. So we have to configure the core.autocrlf accordingly.
For Windows, typically when you accept default settings from Git installer, it will set it automatically to true. But just in case you checked the wrong option or you wanted to be sure, you can configure it manually.
Type the following in Git Bash:
git config --global core.autocrlf = true
For macOS, type the following in Terminal:
git config --global core.autocrlf = input
Now you can verify all your configuration settings by typing this command:
git config --global --list
If you found any typo, you can always fix it by running the same command line with the correct information.
That’s it. This configuration typically is done just once.
Next, while optional, you might want to check this post if you want to use your favorite text editor as the default.