Pular para o conteúdo principal

Installing Git

Module 00 30 min

Section Objectives

  • Install Git on your operating system
  • Verify the installation works correctly
  • Understand the difference between Git CLI and Git GUI
  • Install GitHub CLI for full GitHub management from the terminal

Installation by Operating System

Windows Installation

Recommended Method: Official Git for Windows Installer

  1. Go to git-scm.com/download/win
  2. The download starts automatically (64-bit version)
  3. Run the installer and follow these recommended options:
Installer ScreenRecommended Choice
ComponentsKeep defaults (Git Bash Here, Git GUI Here)
Default editorVS Code (or your preferred editor)
Initial branch namemain
PATH environmentGit from command line and 3rd-party software
SSH executableUse bundled OpenSSH
HTTPS transportUse the OpenSSL library
Line endingsCheckout Windows-style, commit Unix-style
Terminal emulatorUse MinTTY (default)

Verify the installation:

git --version
# Expected output: git version 2.x.x.windows.x

Alternative: Installation via winget

winget install --id Git.Git -e --source winget

Alternative: Installation via Chocolatey

choco install git

Installing GitHub CLI

GitHub CLI (gh) lets you manage GitHub repositories, pull requests, and issues directly from your terminal.

# Via winget
winget install --id GitHub.cli

# Via Chocolatey
choco install gh

Authenticate with GitHub:

gh auth login
# Follow the prompts to authenticate via browser or token

Verify:

gh --version
gh auth status

Git GUI Interfaces (Optional)

While the command line is the recommended approach in this course, these tools can help visualize Git history:

ToolPlatformFree?Description
VS Code (built-in)AllYesBasic Git UI in the editor
GitLens (VS Code extension)AllYesAdvanced Git visualizer in VS Code
GitHub DesktopWin/MacYesSimple GUI for GitHub workflows
SourcetreeWin/MacYesFeature-rich GUI by Atlassian
GitKrakenAllPartialProfessional GUI (free for public repos)
ForkWin/MacPaidVery fast and clean GUI
CLI First

This course focuses on the command line. Understanding Git commands is essential before using a GUI. A GUI can hide what's really happening and make debugging much harder.


Verifying Your Complete Installation

Run these commands in your terminal and check the output:

# Check Git
git --version
# ✅ git version 2.x.x

# Check GitHub CLI
gh --version
# ✅ gh version 2.x.x

# Check Git is accessible everywhere (not just Git Bash on Windows)
# Open PowerShell or cmd.exe (Windows) or regular terminal (Mac/Linux)
git --version
# ✅ Should work from any terminal

Troubleshooting

"git" is not recognized as a command (Windows)

This means Git is not in your PATH. Solutions:

  1. Reinstall Git and choose "Git from command line and 3rd-party software" when asked about PATH
  2. Manually add Git to PATH:
    • Open System Properties → Environment Variables
    • Add C:\Program Files\Git\cmd to the PATH variable
  3. Use Git Bash instead of PowerShell (Git Bash is always configured)
Old version of Git on macOS

macOS includes a very old Apple-patched Git. Install via Homebrew and ensure /usr/local/bin comes before /usr/bin in your PATH:

# Add to ~/.zshrc or ~/.bash_profile
export PATH="/usr/local/bin:$PATH"

# Reload config
source ~/.zshrc

# Verify it's the Homebrew version
which git
# /usr/local/bin/git ✅ (not /usr/bin/git ❌)
Permission denied during Linux installation

You need root (sudo) privileges to install packages. If you don't have sudo access, contact your system administrator or compile Git from source in your home directory.


Next Steps