Skip to the content.

Git configuration - Mac, Windows or Linux

Git comes with a tool called git config that lets you get and set configuration variables that control all aspects of how Git looks and operates. These variables can be stored in three different places:

Each level overrides values in the previous level, so values in .git/config trump those in /etc/gitconfig.

📋 View all of your git config settings and where they are coming from.

Not sure how? ``` # list all local images: git config --list --show-origin ```

Configure your Identity in git

Every Git commit uses this information, and it’s immutably baked into the commits you start creating. You need to do this only once if you pass the --global option, because then Git will always use that information for anything you do on that system

git config --global user.name <Your name> # This 
git config --global user.email <Your email>

Configure your editor

You can configure the default text editor that will be used when Git needs you to type in a message. If not configured, Git uses your system’s default editor.

git config --global core.editor pico

You can find the instructions to set up your favorite editor with Git in git config core.editor commands

Your default branch name

By default Git will create a branch called master when you create a new repository with git init. From Git version 2.28 onwards, you can set a different name for the initial branch.

For more background on this change, this statement from the Software Freedom Conservancy is an excellent place to look

To set main as the default branch name do:

git config --global init.defaultBranch main

Checking your settings

After making changes check your configuration settings

git config --list

You can also check a specific key’s value by typing

git config user.name