Installing Git
Installing Git takes five minutes. Two installer choices and two config commands save you trouble later.
On this page · 5 min · Beginner
On this page
- Learning objectives
- Explanation
- Step-by-step screens
- Code example
- Step by step
- Real-world use
- Common mistakes
- Best practices
- Remember this
- Practice exercise
- Mini quiz
- Related topics
- My notes
- Reading time
- 5 min
- Difficulty
- Beginner
- Updated
- Nov 25, 2026
Learning objectives#
- Install Git on your operating system
- Choose sensible installer options on Windows
- Set your name and email for commits
- Check the installation from a terminal
Explanation#
Windows: download Git for Windows from git-scm.com and run it. Most defaults are right. Change two: set the default branch name to main (GitHub’s default) and choose Visual Studio Code as Git’s editor. The installer also gives you Git Bash, a terminal with Linux-style commands.
macOS: run git --version in Terminal; if Git is missing, macOS offers to install the Command Line Tools. Or use Homebrew: brew install git. Linux: sudo apt install git (Ubuntu/Debian) or sudo dnf install git (Fedora).
Every commit records an author. Set yours once with git config --global user.name and user.email. Use the same email as your GitHub account (or GitHub’s private noreply address) so commits link to your profile.
Step-by-step screens#
Drawings of github.com, the Git installer, VS Code and a terminal. GitHub changes its layout from time to time; the button names stay the same. The red numbers match the numbered actions under each picture; names on your computer will differ.
Loading pictures…
Code example: Check and configure Git once per computer#
git --version
git config --global user.name "Asha Verma"
git config --global user.email "asha@example.com"
git config --global init.defaultBranch main
git config --global --list
git version 2.47.1.windows.1 user.name=Asha Verma user.email=asha@example.com init.defaultbranch=main
This example is illustrative. Copy or download it and run it in your own environment; the expected output is shown above.
Step-by-step explanation#
- git --version proves Git is installed and on your PATH.
- user.name and user.email are written into every commit you make.
- init.defaultBranch main makes new repositories start on main, like GitHub.
- --list shows the settings saved in your global .gitconfig file.
Real-world use case#
On a new office laptop, a developer installs Git, sets name and email, and can clone the team’s repositories straight away.
Common mistakes#
Git refuses to commit (“Please tell me who you are”) or uses a wrong name that won’t link to your GitHub profile.
Terminals opened before the install don’t see the new PATH. Open a new one.
Best practices#
- Use the same email as on GitHub
- Set main as the default branch
- Pick an editor you know (VS Code)
- Update Git now and then
Remember this#
git --version checks the install.
Set user.name and user.email once with --global.
Default branch: main.
Practice exercise#
Your task: Show only the email address Git will use for your commits.
Show solution
git config user.email
Mini quiz#
Why should user.email match your GitHub account?
Want more? Practise all Git & GitHub MCQs · Git & GitHub interview questions
My notes#
Saved in this browser.