Git basics

Install Git and set your name

Install Git and tell it who you are, so your commits are signed with your name.

Fill these in once
  1. Install Git
    Terminal
    brew install git

    No Homebrew yet? Run xcode-select --install instead.

  2. Set your name and email
    Terminal
    git config --global user.name "Ada Lovelace"
    git config --global user.email "you@example.com"
  3. Name new branches "main"
    Terminal
    git config --global init.defaultBranch main

Check it worked

  1. See your settings
    Terminal
    git config --global --list
Undo it
  1. Remove your Git settings
    Terminal
    rm ~/.gitconfig
  1. Install GitNeeds sudo
    Terminal · Ubuntu / Debian
    sudo apt install -y git
  2. Set your name and email
    Terminal · Ubuntu / Debian
    git config --global user.name "Ada Lovelace"
    git config --global user.email "you@example.com"
  3. Name new branches "main"
    Terminal · Ubuntu / Debian
    git config --global init.defaultBranch main

Check it worked

  1. See your settings
    Terminal · Ubuntu / Debian
    git config --global --list
Undo it
  1. Remove your Git settings
    Terminal · Ubuntu / Debian
    rm ~/.gitconfig
  1. Install Git
    PowerShell
    winget install --id Git.Git -e

    Close and reopen PowerShell afterwards so it can find git.

  2. Set your name and email
    PowerShell
    git config --global user.name "Ada Lovelace"
    git config --global user.email "you@example.com"
  3. Name new branches "main"
    PowerShell
    git config --global init.defaultBranch main

Check it worked

  1. See your settings
    PowerShell
    git config --global --list
Undo it
  1. Remove your Git settings
    PowerShell
    Remove-Item "$env:USERPROFILE\.gitconfig"

New to Git? I explain it in plain English on Layman Terms.