DEV Community

Aisalkyn Aidarova
Aisalkyn Aidarova

Posted on

Git install

Windows — Install Git (step by step)

Option A — Easiest (official installer)

  1. Download
  1. Run the installer
  • Double-click the .exe.
  • When the wizard asks:

    • Adjusting your PATH → choose “Git from the command line and also from 3rd-party software”.
    • Default editor → choose Vim (default) or pick Notepad++/VS Code if you prefer.
    • Let Git decide line endings → choose “Checkout Windows-style, commit Unix-style (recommended)”.
    • Git Credential ManagerEnable (recommended).
    • SSH executableUse bundled OpenSSH.
    • Terminal emulatorUse Windows’ default console (or MinTTY if you like).
    • Enable file system cachingYes.
    • Leave other defaults unless you know you need something else.
  1. Verify installation
  • Open Command Prompt or PowerShell and run:

     git --version
    

    You should see a version number.

  1. Configure your identity
   git config --global user.name "Your Name"
   git config --global user.email "you@example.com"
Enter fullscreen mode Exit fullscreen mode
  1. (Optional but recommended) Set default branch name to main
   git config --global init.defaultBranch main
Enter fullscreen mode Exit fullscreen mode
  1. (Optional) Improve credential & line ending behavior
   git config --global core.autocrlf true
   git config --global credential.helper manager
Enter fullscreen mode Exit fullscreen mode
  1. (Optional) Install Git LFS (for large files)
  • Re-run the Git installer and tick Git LFS, or:

     winget install Git.GitLFS
     git lfs install
    

Option B — Using Winget (built-in on modern Windows 10/11)

winget install --id Git.Git -e
git --version
Enter fullscreen mode Exit fullscreen mode

Option C — Using Chocolatey (if you already use choco)

choco install git -y
git --version
Enter fullscreen mode Exit fullscreen mode

macOS — Install Git (step by step)

Option A — Using Homebrew (recommended if you already use brew)

  1. Install Homebrew (if you don’t have it)
   /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
   brew update
Enter fullscreen mode Exit fullscreen mode
  1. Install Git
   brew install git
   git --version
Enter fullscreen mode Exit fullscreen mode

Option B — Xcode Command Line Tools (no Homebrew needed)

  1. Run:
   xcode-select --install
Enter fullscreen mode Exit fullscreen mode
  1. In the popup, choose Install.
  2. Verify:
   git --version
Enter fullscreen mode Exit fullscreen mode

Option C — Official macOS installer

  1. Download the latest .pkg from https://git-scm.com/download/mac
  2. Open the .pkg → follow the prompts.
  3. Verify:
   git --version
Enter fullscreen mode Exit fullscreen mode

Configure Git on macOS

  1. Identity
   git config --global user.name "Your Name"
   git config --global user.email "you@example.com"
Enter fullscreen mode Exit fullscreen mode
  1. Default branch
   git config --global init.defaultBranch main
Enter fullscreen mode Exit fullscreen mode
  1. Credentials stored in Keychain
   git config --global credential.helper osxkeychain
Enter fullscreen mode Exit fullscreen mode

One-time SSH setup (Windows & macOS)

Use this if you’ll push to GitHub/GitLab/Bitbucket over SSH (recommended for fewer password prompts).

  1. Generate a key (ed25519)
   ssh-keygen -t ed25519 -C "you@example.com"
Enter fullscreen mode Exit fullscreen mode
  • Press Enter to accept default location (~/.ssh/id_ed25519).
  • Optionally set a passphrase.
  1. Start the SSH agent & add your key
  • macOS (zsh/bash):

     eval "$(ssh-agent -s)"
     ssh-add ~/.ssh/id_ed25519
    
  • Windows PowerShell (Git Bash similar):

     eval "$(ssh-agent -s)"
     ssh-add ~/.ssh/id_ed25519
    
  1. Copy your public key
  • macOS:

     pbcopy < ~/.ssh/id_ed25519.pub
    
  • Windows (PowerShell):

     Get-Content $env:USERPROFILE\.ssh\id_ed25519.pub | Set-Clipboard
    
  1. Add to your Git host
  • GitHub: Settings → SSH and GPG keys → New SSH key → paste → Save.
  • GitLab/Bitbucket: similar path under SSH Keys.
  1. Test
   ssh -T git@github.com
Enter fullscreen mode Exit fullscreen mode

You should see a success message (first time may ask to trust the host).


Quick sanity test (both platforms)

mkdir git-test && cd git-test
git init
echo "hello" > README.md
git add README.md
git commit -m "first commit"
git log --oneline
Enter fullscreen mode Exit fullscreen mode

Keeping Git up to date

  • Windows (winget):
  winget upgrade Git.Git
Enter fullscreen mode Exit fullscreen mode
  • Windows (installer): download/run the newest .exe from git-scm.com; it upgrades in place.
  • macOS (Homebrew):
  brew upgrade git
Enter fullscreen mode Exit fullscreen mode
  • macOS (Xcode CLT):

    • Run softwareupdate --all --install --force or reinstall CLT with xcode-select --install.

Common issues & fixes

  • git: command not found

    • Windows: close/reopen terminal; ensure Git is on PATH (re-run installer and select PATH option).
    • macOS: install via xcode-select --install or brew install git.
  • Corporate proxy blocks

    Configure Git to use your proxy:

  git config --global http.proxy http://USER:PASS@proxy.company.com:8080
  git config --global https.proxy http://USER:PASS@proxy.company.com:8080
Enter fullscreen mode Exit fullscreen mode
  • Permission denied (publickey) Your SSH key isn’t added or not uploaded to Git host. Re-run the SSH steps above and test with:
  ssh -T git@github.com
Enter fullscreen mode Exit fullscreen mode
  • Multiple Git versions on macOS Check which Git runs:
  which git
Enter fullscreen mode Exit fullscreen mode

Prefer Homebrew Git (/usr/local/bin/git on Intel, /opt/homebrew/bin/git on Apple Silicon). If needed, adjust your shell PATH to put Homebrew first.

Top comments (0)