Install Git on Linux, macOS and Windows
Install Git from your package manager, Xcode's command line tools or the Windows installer, confirm the version, and do the one-time configuration of name, email and default branch.
Drafted with AI from official documentation. Scripts were run in a test environment and repository links verified. Awaiting a human check. Did it work for you? Last edited Outdated?
Which option to pick
Git is in every Linux distribution’s repositories and that is the normal way to install it. On macOS the quickest route is Apple’s command line tools, which include Git; Homebrew gives a newer version. On Windows, Git for Windows from git-scm.com is the standard package and also provides Git Bash, a Unix-style shell, which most tutorials assume. Any version from the last few years is fine for everyday work.
Step: Linux
Check before you run this
- Runs with administrator rights. Make sure you understand every line.
sudo apt update
sudo apt install git
Fedora and RHEL use sudo dnf install git, Arch sudo pacman -S git, openSUSE sudo zypper install git. On Ubuntu, if you need the very latest release, the Git maintainers publish a PPA: sudo add-apt-repository ppa:git-core/ppa, then sudo apt update && sudo apt install git.
Step: macOS
xcode-select --install
A dialog asks to install the command line developer tools; this includes Git. Simply typing git in a terminal on a fresh Mac triggers the same prompt. For a current version maintained independently of macOS updates:
brew install git
Homebrew’s Git comes first in PATH on Apple Silicon Macs by default; check with which git.
Step: Windows
winget install Git.Git
Or download the installer from git-scm.com/downloads/win. The defaults are sensible: keep Git from the command line and also from 3rd-party software so git works in PowerShell, and keep Checkout Windows-style, commit Unix-style line endings unless your team says otherwise. After installing, open a new terminal window.
Check it works
git --version
Then tell Git who you are and which name new repositories should use for their first branch. These settings are stored in ~/.gitconfig and apply to all your repositories:
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
git config --global init.defaultBranch main
git config --global --list
Use the email address associated with your GitHub or GitLab account so commits are linked to you.
Common problems
- macOS:
xcrun: error: invalid active developer pathafter a macOS upgrade. The command line tools need reinstalling; runxcode-select --installagain. - Windows:
gitis not recognised in PowerShell after installing: open a new window, or re-run the installer and choose the PATH option described above. - Windows: files show as modified immediately after cloning: a line-ending mismatch. Set
git config --global core.autocrlf trueon Windows, or let the project control it with a.gitattributesfile. - Every push asks for a password: GitHub and GitLab no longer accept account passwords over HTTPS. Use SSH keys, or a credential helper with a personal access token (
git config --global credential.helper manageron Windows,osxkeychainon macOS,libsecretorstoreon Linux).
Official documentation
Did this work for you?
No votes yet. Be the first.
If it did not work, the report form below tells the editors what went wrong.
See also
- 0032 First-time Git setup: name, email, default branch, SSH or HTTPS Tell Git who you are, pick sensible defaults, and choose between SSH and HTTPS for GitHub. Includes a small script that applies… Beginner · Step by step · Linux, macOS, Windows Script Setup 15 Oct 2026
- 0033 The everyday Git workflow: status, add, commit, push, pull Git moves your changes through three places: the working folder, the staging area, and the commit history. These five commands, plus .gitignore… Beginner · Explains an idea · Any system Article Housekeeping · Setup 15 Oct 2026
- 0262 Make your first pull request: Git and GitHub from first commit to merged change A complete beginner's path through Git and GitHub: set up Git, make commits, ignore files, use branches, push to GitHub, open a… Beginner · Guided project · Any system Article Branching & rebasing · Pull requests · Setup 15 Oct 2026
- 0318 Fix: fatal: not a git repository Git looked in the current directory and every parent for a .git folder and found none. You are in the wrong directory,… Beginner · Fixes an error · Any system Article Common errors · Setup 15 Oct 2026
- 0381 pre-commit hooks: catch mistakes before they are committed Install the pre-commit framework, configure hooks for whitespace, YAML and JSON syntax, large files, leaked private keys, Python linting and shellcheck, run… Beginner · Step by step · Linux, macOS, Windows Article Pipelines, runners & hooks · Setup 15 Oct 2026
- 0386 Install Node.js on Linux, macOS and Windows Get Node.js and npm on any desktop OS. Use a version manager (nvm or fnm) when you work on several projects, or… Beginner · Step by step · Linux, macOS, Windows Article Installing languages & tools · Node.js 15 Oct 2026
History
Every saved edit is kept. The plot on the sleeve draws one line per edit. Open any edit to see exactly what changed.
- Dominik +2,904 chars