0
0
GitHow-ToBeginner · 3 min read

How to Configure Git Globally: Simple Steps

To configure Git globally, use the git config --global command followed by the setting name and value, such as user.name and user.email. This sets your identity for all Git repositories on your computer.
📐

Syntax

The basic syntax to configure Git globally is:

  • git config --global <setting-name> <value>
  • --global means the setting applies to all repositories for your user.
  • <setting-name> is the configuration key like user.name or user.email.
  • <value> is the value you want to set, such as your name or email address.
bash
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
💻

Example

This example sets your global Git username and email, which Git uses to label your commits across all projects.

bash
git config --global user.name "Alice Developer"
git config --global user.email "alice@example.com"
git config --global --list
Output
user.name=Alice Developer user.email=alice@example.com
⚠️

Common Pitfalls

Common mistakes include:

  • Forgetting to use --global, which sets the config only for the current repository.
  • Typing the setting name incorrectly, like username instead of user.name.
  • Not quoting values with spaces, causing errors.

Always double-check your commands to avoid these issues.

bash
git config user.name "Wrong User"
# This sets username only for current repo, not globally

git config --global username "Wrong User"
# Incorrect key, should be user.name

git config --global user.name Alice Developer
# Missing quotes around name with spaces causes error

git config --global user.name "Alice Developer"
# Correct way
📊

Quick Reference

CommandDescription
git config --global user.name "Your Name"Set your global Git username
git config --global user.email "you@example.com"Set your global Git email
git config --global --listShow all global Git settings
git config user.name "Name"Set username only for current repo (no --global)

Key Takeaways

Use git config --global to set your username and email for all repositories.
Always quote values with spaces to avoid errors.
Check your settings anytime with git config --global --list.
Without --global, settings apply only to the current repository.
Use correct keys like user.name and user.email to avoid mistakes.