Configuring Git
Open a Terminal and follow along with the instructions below.
Checking your Git version
First, let’s confirm your Git Installation:
git version
If Git is installed, it will return your version. Eg: git version 2.46.1.windows.1
If you do not see a Git version listed or this command returns an error, you may need to install Git.
Git configuration levels
Git allows you to set configuration options at three different levels.
—system
These are system-wide configurations. They apply to all users on this computer.
—global
These are the user level configurations. They only apply to your user account.
—local
These are the repository level configurations. They only apply to the specific repository where they are set.
The default value for git config is —local.
Viewing your configurations
If you would like to see which config settings have been added automatically, you can type git config —list. This will automatically read from each of the three config files and list the setting they contain.
git config --list
You can also narrow the list to a specific configuration level by including it before the list option.
git config --global --list
Configuring your info
Git uses the config settings for your user name and email address to generate a unique fingerprint for each of the commits you create. You can’t create commits without these settings:
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
Example:
git config --global user.name "John Smith"
git config --global user.email "[email protected]"
If you make a typo when setting one of your config properties, don’t worry. You can rerun the same git config
command with different values between the double quotes to update the property to a new value. If you typo a property name, you can delete the property with the following command:
git config --global --unset <property_name>
Configuring autocrlf
# for Windows users
git config --global core.autocrlf true
# for Mac or Linux users
git config --global core.autocrlf input
Different systems handle line endings and line breaks differently. If you open a file created on another system and do not have this config option set, Git will think you made changes to the file based on the way your system handles this type of file.