← Back to Git Course | Chapter 1: Introduction & Setup | Lesson 4 of 7

Git Configuration

Git configuration is like writing your name on your school notebook so everyone knows whose work it is. Git will not let you save a version until it knows your name and email.
Syntax
bash
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
git config --global core.editor "editor_name"

Setting Your Username

Git refuses to let you commit until it knows who you are, so before your first commit you set your name globally with git config --global user.name, and that name gets permanently baked into every snapshot you save.

Example: Setting Your Username

bash
git config --global user.name "Your Name"

Setting Your Email

Alongside your name, Git also records your email address on every commit -- this is the value platforms like cookiescursor.com use to match your commits to your account, so it's worth double-checking it matches what you registered there.

Example: Setting Your Email

bash
git config --global user.email "[email protected]"

Setting the Default Editor

When a command needs you to type a message (like an interactive commit), Git launches whatever text editor you've configured -- Nano is beginner-friendly, Vim is fast once learned, and VS Code can be set as the default if you prefer a GUI.

Example: Setting the Default Editor

bash
git config --global core.editor "code --wait"

Listing Your Configurations

Running git config --list prints every active setting Git is currently using, along with which config file each one came from, which is the fastest way to debug 'why is Git doing that' when behavior doesn't match what you expect.

Example: Listing Your Configurations

bash
git config --list

Scope of Configurations

Git configuration is layered in three scopes: --system applies to every user on the machine, --global applies only to your user account, and --local applies only inside the current repository -- with local settings overriding global ones when they conflict.

Example: Scope of Configurations

bash
git config --system --list
git config --global --list
git config --local --list
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
Common Mistakes
  1. Skipping git config --global user.name and user.email, so commits show the wrong or a guessed identity or Git refuses to commit.
  2. Leaving out --global so the setting only applies to one repository and the next repository asks again.
  3. Using an email that differs from your GitHub account email, so commits are not linked to your profile.
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.