git config
git config
: configure your Git settings.
git config
is a command used to set configuration options for your Git installation, affecting how Git behaves and looks for you. These settings can be related to your identity (name and email), the styling of command output, the default editor for writing commit messages, and much more. These configurations help in personalizing the Git setup to suit your workflow.
Configuration levels in Git include:
- Local: Configuration settings for the specific repository you are working in.
- Global: Configuration settings for your user account on your computer, affecting all repositories you work with.
Using git config
, you can manage these settings across different levels, allowing for fine-grained control of Git's behavior. For example, setting your email address at the global level means every commit across all projects on your computer will include that email address as the author.
When you first set up Git, it's a good idea to configure your global settings, which will apply to all repositories you work with on your machine. You can also override these global settings on a per-repository basis if needed.
Examples
Get your global user name configuration:
git config --global user.name
Set your user name and email address globally:
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
Set the default branch name for new repositories:
git config --global init.defaultBranch "main"
Set your preferred text editor (e.g., VSCode) globally:
git config --global core.editor "code --wait"
List all global configuration settings:
git config --global --list
Set a repository-specific user email address. We omit the --global
option to set this configuration only in the current repository:
git config user.email "work.email@example.com"