Your Digital Identity
Every astronaut needs identification. When you make changes to your code, Git records who made them. This isn't about surveillance—it's about collaboration and accountability. Let's configure Git with your identity.
Essential Configuration
Setting Your Name
Tell Git who you are:
git config --global user.name "Your Name"
Example:
git config --global user.name "Commander Shepard"
Setting Your Email
Configure your email address:
git config --global user.email "your.email@example.com"
Example:
git config --global user.email "shepard@normandy.space"
Important: If you plan to use GitHub, use the email associated with your GitHub account.
Understanding Configuration Levels
Git has three configuration levels:
- System: Applies to all users on the computer (
--system) - Global: Applies to all your repositories (
--global) - Local: Applies to a specific repository (no flag, or
--local)
Most of the time, you'll use --global. Local settings override global, which override system.
Configuring Your Default Editor
Git sometimes opens a text editor (like for commit messages). Set your preferred editor:
VS Code:
git config --global core.editor "code --wait"
Vim:
git config --global core.editor "vim"
Nano:
git config --global core.editor "nano"
Notepad (Windows):
git config --global core.editor "notepad"
Line Ending Configuration
Different operating systems use different line endings. Configure Git to handle this:
Windows:
git config --global core.autocrlf true
Mac/Linux:
git config --global core.autocrlf input
Viewing Your Configuration
See all configuration settings:
git config --list
See a specific setting:
git config user.name
git config user.email
Useful Optional Configurations
Color Output
Make Git output colorful and easier to read:
git config --global color.ui auto
Default Branch Name
Set the name for your default branch (GitHub uses "main"):
git config --global init.defaultBranch main
Pull Behavior
Configure how Git handles pulls:
git config --global pull.rebase false
Configuration File Locations
Git stores configuration in files:
- Global:
~/.gitconfig(or~/.config/git/config) - Local:
.git/configin each repository
You can edit these files directly, but using git config commands is safer.
Verifying Your Setup
Let's verify everything is configured correctly:
git config --global --list
You should see at least:
user.name=Your Name
user.email=your.email@example.com
Quick Setup Script
Here's a complete basic configuration you can copy and paste (replace with your details):
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
git config --global core.editor "code --wait"
git config --global init.defaultBranch main
git config --global color.ui auto
Changing Configuration Later
You can change any setting anytime by running the config command again:
git config --global user.email "newemail@example.com"
Removing Configuration
Remove a setting:
git config --global --unset user.name
Why This Matters
Every commit you make includes your name and email. This allows:
- Team members to know who wrote code
- Future you to remember what you were thinking
- Project maintainers to contact contributors
- GitHub to link commits to your profile
It's like signing your work—professional and essential for collaboration.
Configuration Complete
Your spacecraft systems are now configured. Git knows who you are and has sensible defaults for everything else. You're ready to learn about GitHub—mission control for your code.
Configuration Check: Your Git identity is set. Every commit will now be properly attributed to you. This is a one-time setup—you won't need to do it again unless you get a new computer or want to change your details.