M
MeshWorld.
HowTo Git Ubuntu macOS Windows Install Version Control Developer Tools 4 min read

How to Install Git on Ubuntu, macOS and Windows

By Vishnu Damwala

Git comes pre-installed on many systems but often at an outdated version. Here’s how to install or update Git on each platform, followed by the first-time setup every developer should do before making their first commit.


Install Git on Ubuntu / Debian Linux

sudo apt update
sudo apt install git -y

Verify:

git --version

Get a newer Git version (optional)

Ubuntu’s default repos can lag behind. If you need a recent version:

sudo add-apt-repository ppa:git-core/ppa
sudo apt update
sudo apt install git -y
git --version

Install Git on macOS

brew install git

If you don’t have Homebrew:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Then install Git:

brew install git
git --version

Method 2: Xcode Command Line Tools

macOS ships with a Git stub that triggers the Xcode CLT installer when you first run it:

git --version

A dialog will appear asking to install the Command Line Tools. Click Install. This gives you Apple’s version of Git — slightly behind upstream but sufficient for most use.


Install Git on Windows

Method 1: winget (fastest)

winget install Git.Git

Restart your terminal after installation.

Method 2: Official installer

Download from git-scm.com and run the installer.

Key options during install to pay attention to:

  • Default editor: change from Vim to VS Code or Notepad++ if you prefer
  • Line ending conversions: “Checkout Windows-style, commit Unix-style” is the standard choice for most developers
  • Git Bash: keep this checked — it gives you a Linux-style shell on Windows

After install, open Git Bash or PowerShell:

git --version

First-time Git setup (do this on every new machine)

After installing Git, run these two commands before you do anything else. Every commit you make will be tagged with this information.

git config --global user.name "Your Name"
git config --global user.email "[email protected]"

Set your default branch name to main (the modern standard):

git config --global init.defaultBranch main

Set your preferred editor for commit messages:

# VS Code
git config --global core.editor "code --wait"

# Nano (much friendlier than Vim for quick edits)
git config --global core.editor "nano"

# Vim (if you're comfortable with it)
git config --global core.editor "vim"

Verify your config:

git config --list

Connecting Git to GitHub / GitLab

SSH keys let you push without entering a password every time.

# Generate a key (use your actual email)
ssh-keygen -t ed25519 -C "[email protected]"

# Start the SSH agent
eval "$(ssh-agent -s)"

# Add your key
ssh-add ~/.ssh/id_ed25519

# Copy the public key to your clipboard
cat ~/.ssh/id_ed25519.pub

On macOS, pipe to pbcopy:

cat ~/.ssh/id_ed25519.pub | pbcopy

On Windows (Git Bash):

cat ~/.ssh/id_ed25519.pub | clip

Then paste it into GitHub → Settings → SSH and GPG keys → New SSH key.

Test the connection:

ssh -T [email protected]

You should see: Hi username! You've successfully authenticated.


Updating Git

Ubuntu:

sudo apt update && sudo apt upgrade git

macOS (Homebrew):

brew upgrade git

Windows (winget):

winget upgrade Git.Git

Quick Git commands to get started

git init                    # initialize a new repo
git clone <url>             # clone an existing repo
git status                  # see what's changed
git add .                   # stage all changes
git commit -m "message"     # commit
git push                    # push to remote
git pull                    # pull latest changes
git log --oneline           # see commit history

Next step: Set Up SSH Keys for GitHub so you never have to type a password again.