Installing Git and Initial Configuration (git config user.name / email)0%
Initializing a Repository (git init and .git Directory Anatomy)

Installing Git and Initial Configuration (git config user.name / email)

Beginner12 min read•Updated: Jul 11, 2026
Study MaterialsCheatsheet

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

  1. 1
    Download the official installer from git-scm.com (Git for Windows).
  2. 2
    Run the .exe installer. 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:

Bash / Terminal
# Using Homebrew (Recommended)
brew install git
 
# Or trigger Apple Xcode Command Line Developer Tools
xcode-select --install

C. Linux (Ubuntu / Debian / Fedora)

Bash / Terminal
# Ubuntu / Debian
sudo apt update
sudo apt install git -y
 
# Fedora / RHEL
sudo dnf install git -y

Verify Installation:

Open your terminal (PowerShell, Command Prompt, macOS Terminal, or Linux Bash) and verify:

Bash / Terminal
git --version
# Expected output: git version 2.40.0 (or newer)

2. The Three Levels of Git Configuration

Git configurations can be applied at three different scopes:

Scope FlagConfig File LocationScope 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 .gitconfigApplies to the current operating system user across all their repos
--local.git/config inside the active repository folderApplies only to this specific project repository
Pro Tip
[!TIP] Git evaluates configurations in order of precedence: --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:

Bash / Terminal
# Set your full name
git config --global user.name "Sumit Sharma"
 
# Set your email address (use your GitHub-associated email)
git config --global user.email "sumit@mskinstitute.com"

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:

Bash / Terminal
git config --global init.defaultBranch main

Step 3: Set Your Preferred Code Editor

Configure VS Code as Git's default text editor for commit messages and interactive rebasing:

Bash / Terminal
git config --global core.editor "code --wait"

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:

Bash / Terminal
# On Windows machines:
git config --global core.autocrlf true
 
# On macOS and Linux machines:
git config --global core.autocrlf input

4. Inspecting and Verifying Your Configuration

To review all active configuration parameters:

Bash / Terminal
# List all resolved configurations
git config --list
 
# Show where each configuration setting originates
git config --list --show-origin
 
# Check a single specific setting
git config user.name
# Output: Sumit Sharma

Interactive Quiz

Practice Quiz

Question 1
Which git config scope applies settings across all repositories for the currently logged-in user?
Question 2
What happens if a repository has a --local setting that conflicts with a --global setting?
Question 3
Why is configuring user.name and user.email mandatory in Git?
Question 4
What is the purpose of configuring core.autocrlf = true on a Windows developer workstation?
Question 5
Which command verifies the currently installed version of Git in your terminal?
Next Lesson

Initializing a Repository (git init and .git Directory Anatomy)

Continue learning with hands-on practice, examples, and exercises in the upcoming topic.

Practice Quiz

Test your understanding of this lesson with 5 questions. Each question has one correct answer.

PrevNext