Class 3 of 50 • Git Fundamentals

Git Installation & Global Configuration: Windows, macOS and Linux

Before writing any code or tracking repositories, you must install the official Git binaries on your development machine and configure your author identity. Every Git commit you create embeds this identity permanently into the commit history.

Step 1: Installing Git Across Operating Systems

1. Installing Git on Microsoft Windows

For Windows developers, the official installer provides Git Bash (a lightweight Unix-like shell environment that includes standard Unix command-line utilities like ls, grep, cat, and ssh):

  1. Navigate to the official Git website: git-scm.com/download/win.
  2. Download the 64-bit Git for Windows Setup installer executable.
  3. Run the installer. Keep the default selections recommended by the installer:
    • Default editor: Select Visual Studio Code (or your preferred editor).
    • Adjusting your PATH environment: Select "Git from the command line and also from 3rd-party software".
    • Line ending conversions: Select "Checkout Windows-style, commit Unix-style line endings" (core.autocrlf = true).
    • Terminal emulator: Select "Use MinTTY (the default terminal of MSYS2)".
  4. Click Install and finish the setup.

2. Installing Git on macOS

The cleanest way to install and maintain Git on macOS is using the Homebrew package manager:

# Install Homebrew if not already present
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# Install latest Git version
brew install git

Alternatively, opening Terminal and typing git --version will prompt Apple's Xcode Command Line Tools installer if Git is not yet installed.

3. Installing Git on Linux (Ubuntu, Debian, Fedora, CentOS)

On Linux distributions, use the native system package manager:

# For Ubuntu / Debian / Linux Mint:
sudo apt update
sudo apt install git -y

# For Fedora / Red Hat Enterprise Linux / Rocky Linux:
sudo dnf install git -y

# For Arch Linux:
sudo pacman -S git

Step 2: Verifying the Installation

Open your terminal (PowerShell, Command Prompt, Git Bash, or Terminal on Mac/Linux) and verify the installed version:

$ git --version
git version 2.44.0

Step 3: Essential First-Time Global Configuration

Git comes with a built-in configuration tool called git config that lets you set configuration variables. These variables are stored in three different levels:

  • --system: Applied to all users on the operating system (stored in /etc/gitconfig).
  • --global: Applied to your specific user profile across all repositories (stored in ~/.gitconfig).
  • --local: Applied only to the current repository (stored in .git/config).

You must set your author name and email address. This is critical because every single Git commit binds this metadata into its cryptographic hash:

# Set your global username
git config --global user.name "John Doe"

# Set your global email address (use your GitHub-associated email)
git config --global user.email "john.doe@example.com"

Configuring Default Initial Branch Name (main)

Historically, Git defaulted to naming the primary branch master. In 2020, GitHub and the open-source community adopted main as the modern, inclusive standard. Configure Git to automatically initialize new repositories with main:

git config --global init.defaultBranch main

Setting Line Ending Handling (core.autocrlf)

Windows uses Carriage Return and Line Feed (CRLF) for line breaks, while macOS and Linux use Line Feed (LF). To prevent spurious diffs across cross-platform teams:

# On Windows:
git config --global core.autocrlf true

# On macOS and Linux:
git config --global core.autocrlf input

Setting Your Default Code Editor

# To use Visual Studio Code:
git config --global core.editor "code --wait"

# To use Nano:
git config --global core.editor "nano"

# To use Vim:
git config --global core.editor "vim"

Step 4: Inspecting Your Active Configuration

To inspect all configured values and see which file they originate from, run:

git config --list --show-origin

BCA Exam Viva Tip

If an interviewer asks: "Where are Git global configurations stored on a user's machine?", answer: "In the user's home directory inside the hidden file named .gitconfig (e.g. C:\Users\username\.gitconfig on Windows or ~/.gitconfig on Linux/Mac)."

Explore Related Git & GitHub Tutorials & Next Steps

Strengthen your version control mastery by studying these connected classes:

Initializing & Cloning Repositories

Run git init to create new repos or git clone to download remote codebases.

SSH Key Authentication Setup

Generate secure ed25519 SSH keys for passwordless authentication with GitHub.

.gitignore Rules & Configuration

Prevent node_modules, .env, and build artifacts from leaking into commits.

Complete Git Command Cheat Sheet

Quick-reference guide for all daily Git CLI options and configuration flags.

Frequently Asked Questions (FAQ) - Student & Interview Review

Yes! The `--global` email acts as your default fallback. In any specific work repository, navigate to that folder in terminal and omit the `--global` flag: `git config user.email 'work@company.com'`. This saves the configuration locally inside `.git/config` for that repository only.
Git Bash is an application package for Microsoft Windows environments that provides an emulation layer for a Bash command-line experience. It includes standard Unix utilities (like ssh, scp, cat, grep, find, and awk) alongside the Git CLI, allowing Windows developers to use identical terminal commands as Linux and macOS engineers.
No. Updating `git config` only changes the author metadata embedded into future commits. All previously recorded commits remain immutable with their original author information.

Next Step in Your Git & GitHub Learning Path:

Advance your software engineering skills with the next topic in our synchronized curriculum.

Continue to Three-Tree Architecture → Previous: ← Intro & VCS History | Full Syllabus

Share Share on Facebook Share on Twitter Share on LinkedIn Pin on Pinterest Share on Reddit

You may also like this!