Related
Initialize Repository
Create an empty Git repository in a directory to start version controlling your project
Clone Repository
Clone an existing Git repository from a remote server to your local machine, creating a complete copy with full history
Check Repository Status
Display the current state of your working directory and staging area, showing which files are modified, staged, or untracked
Command
git configExplanation
The git config command is used to set and view Git configuration options at three levels: system-wide (applies to all users), global (applies to current user), and local (applies to specific repository). Configuration options control how Git behaves, including user identity (name and email), default editor, merge tools, aliases, and many other settings. User name and email are essential as they're attached to every commit you make, helping identify authorship in project history. The --global flag sets options for your user account across all repositories, while local settings (no flag) apply only to the current repository. You can view configurations with git config --list and check specific values with git config <key>. Common configurations include setting up default branch names, configuring merge strategies, creating command aliases for frequently used commands, and setting up credential helpers for authentication. Proper Git configuration is crucial for professional development workflows and ensures your commits are properly attributed and your Git experience is optimized for your workflow.
Common Use Cases
- •Setting up Git for the first time on a new machine
- •Configuring user identity for commit attribution
- •Setting up default editor and merge tools
- •Creating command aliases for productivity
- •Configuring repository-specific settings
Best Practices
- ✓Set global user.name and user.email immediately after installing Git
- ✓Use --global for personal preferences (editor, aliases)
- ✓Use local config for project-specific settings
- ✓Create aliases for frequently used long commands
- ✓Verify configuration with git config --list before starting work
Common Mistakes to Avoid
- ⚠Forgetting to set user.name and user.email before first commit
- ⚠Using --global when repository-specific config is needed
- ⚠Setting email incorrectly leading to wrong GitHub attribution
- ⚠Not configuring default editor, causing unexpected editor launches
Troubleshooting
Problem: Commits show wrong author name or email
Solution: Check config with git config user.name and git config user.email. Set with --global flag if needed.
Problem: Git opens wrong text editor
Solution: Configure your preferred editor with git config --global core.editor "your-editor-command".
Examples
Set global username
git config --global user.name "Your Name"Set global email
git config --global user.email "email@example.com"View all configurations
git config --listSet default branch name to main
git config --global init.defaultBranch mainSet VS Code as default editor
git config --global core.editor "code --wait"Create alias st for status
git config --global alias.st status