Git & GitHub
/Beginner
Git Configuration
Definition
The `git config` command lets you get and set configuration variables that control all aspects of how Git looks and operates.
Explain Like I'm New
Before you save any files, Git needs to know who you are! If you save a file, Git stamps your name and email on it. You have to tell Git your name and email using `git config` when you first install it, or it will yell at you.
Real World Example
Setting your global username and email so that when you push code to GitHub, your profile picture actually shows up next to the code you wrote.
Common Use Cases
- •Identifying authors of commits
- •Setting default text editors
- •Creating command aliases
Terminal Output
bash / terminal
# 1. Set your identity (Crucial!)
$ git config --global user.name "John Doe"
$ git config --global user.email "johndoe@example.com"
# 2. Check your settings to make sure they saved
$ git config --list
# 3. Set your default text editor for commit messages (e.g., VS Code)
$ git config --global core.editor "code --wait"
# 4. Change the default branch name from 'master' to 'main'
$ git config --global init.defaultBranch main
Interview Questions
basic
- What two configurations MUST you set before making your first commit?
intermediate
- What is the difference between `--global` and `--local` config?