What is git config?

Why Interviewers Ask This

This question tests conceptual clarity. Interviewers want to hear a precise, confident definition before moving to more complex Git & GitHub topics. It also reveals how well you can explain technical ideas to non-experts.

Answer

git config reads and writes Git configuration settings at three levels: (1) System: /etc/gitconfig — applies to all users on the machine (--system flag); (2) Global: ~/.gitconfig or ~/.config/git/config — applies to all repos for the current user (--global flag, most common); (3) Local: .git/config — applies only to the current repo (default, --local flag). Higher level overrides lower. Essential initial setup: git config --global user.name "Your Name"; git config --global user.email "you@example.com" — required for commits; git config --global core.editor "code --wait" — set VS Code as editor; git config --global init.defaultBranch main — default branch name. View config: git config --list — show all settings; git config user.name — show specific setting; git config --global --edit — open global config in editor. Useful settings: git config --global pull.rebase true — always rebase on pull; git config --global alias.lg "log --oneline --graph --all" — create command alias; git config --global core.autocrlf input — handle line endings (important on Windows).

Common Mistake

Rushing to answer is a common mistake. Take two seconds to structure your response: definition → example → trade-off. This structure makes complex Git & GitHub answers easy to follow.