Installing Git and Initial Configuration (git config user.name / email)
Installing Git and Initial Configuration (git config user.name / email)
Before creating repositories or writing commits, Git must be properly installed on your operating system and configured with your identity. Every Git commit embeds the author's name and email permanently into its cryptographic hash, making initial configuration essential.
1. Installing Git Across Operating Systems
A. Windows
- 1Download the official installer from git-scm.com (Git for Windows).
- 2Run the
.exeinstaller. Recommended installation settings:
- Default editor: Visual Studio Code (or your preferred editor).
- Default branch name for new repositories:
main(modern standard). - Adjusting your PATH environment: Git from the command line and also from 3rd-party software.
- Line ending conversions: Checkout Windows-style, commit Unix-style line endings (
core.autocrlf = true).
B. macOS
On macOS, Git can be installed via Xcode Command Line Tools or Homebrew:
C. Linux (Ubuntu / Debian / Fedora)
Verify Installation:
Open your terminal (PowerShell, Command Prompt, macOS Terminal, or Linux Bash) and verify:
2. The Three Levels of Git Configuration
Git configurations can be applied at three different scopes:
| Scope Flag | Config File Location | Scope of Effect |
|---|---|---|
--system | /etc/gitconfig (Unix) or C:\Program Files\Git\etc\gitconfig (Windows) | Applies to every user and every repository on the operating system |
--global | ~/.gitconfig or user profile .gitconfig | Applies to the current operating system user across all their repos |
--local | .git/config inside the active repository folder | Applies only to this specific project repository |
--local overrides --global, which overrides --system.3. Essential First-Time Configurations
Step 1: Set Your Identity (Mandatory)
Git requires an author name and email address. These will be stamped onto every commit you ever create:
Step 2: Set Default Initial Branch Name
Historically Git defaulted to master. The modern industry standard adopted by GitHub, GitLab, and the Git community is main:
Step 3: Set Your Preferred Code Editor
Configure VS Code as Git's default text editor for commit messages and interactive rebasing:
Step 4: Configure Line Ending Normalization (core.autocrlf)
Operating systems handle line breaks differently: Windows uses CRLF (\r\n), while macOS and Linux use LF (\n). Without normalization, teams collaborating across Windows and Mac will experience phantom diffs on every line:
4. Inspecting and Verifying Your Configuration
To review all active configuration parameters:
Practice Quiz
git config scope applies settings across all repositories for the currently logged-in user?--local setting that conflicts with a --global setting?user.name and user.email mandatory in Git?core.autocrlf = true on a Windows developer workstation?Initializing a Repository (git init and .git Directory Anatomy)
Continue learning with hands-on practice, examples, and exercises in the upcoming topic.
Related Lessons
Practice Quiz
Test your understanding of this lesson with 5 questions. Each question has one correct answer.