Git configuration allows you to customize how Git behaves on your system. You can define your identity, preferred editor, merge tools, and many other settings globally or per repository.
Git configurations are managed using the git config command. Values can be stored globally or locally depending on the flags used.
// Set global username for all repositories
git config --global user.name "Your Name"
// Set global email address for commits
git config --global user.email "your.email@example.com"
The --global flag applies settings to all repositories. Omitting it applies settings only to the current repository.
// Display all current Git configuration values
git config --list
// Open global Git configuration in default editor
git config --global --edit
// Set Visual Studio Code as the default Git editor
git config --global core.editor "code --wait"
// Configure vimdiff as the default merge tool
git config --global merge.tool vimdiff
// Set repository-specific email address
git config user.email "different.email@example.com"
// Check configured username
git config user.name
// Check configured email
git config user.email
Running these commands prints the currently active configuration values, confirming whether global or local settings are applied.