Installing and Setting Up Git
What you will learn on this page
- Install Git using the method that suits your OS
- Set
user.nameanduser.email - Make
mainthe default branch name - Understand where settings are stored and how to check them
On this page12 items
This is the start of Part 2. Parts 2 through 5 cover Git operations that happen entirely inside your own PC, with no network connection. First, you’ll install Git and tell it “who is recording.”
First, check whether it’s installed#
Open a terminal and type the following command.
git --version
# Output (example):
# git version 2.56.0If you see git version followed by a number, Git is already installed. The number varies with when and how it was installed, but with 2.28 or later you can try everything in this guide. If you see something like command not found, install it using one of the methods in the next section.
Installation by OS#
| OS | Recommended method | Command / where to get it |
|---|---|---|
| Windows | Git for Windows installer | Download from git-scm.com/install/windows |
| Windows (alternative) | winget | winget install --id Git.Git -e --source winget |
| macOS | Xcode Command Line Tools | xcode-select --install |
| macOS (alternative) | Homebrew | brew install git |
| Debian / Ubuntu | apt | sudo apt-get install git |
| Fedora | dnf | sudo dnf install git |
Xcode Command Line Tools on macOS includes a Git provided by Apple. It’s sometimes a slightly older version, but that’s no problem while you’re learning. If you already use Homebrew, brew install git keeps you on a newer version.
Confusing screens in the Windows installer#
The Git for Windows installer has a lot of confirmation screens, but you can generally just accept all the defaults. The two that tend to cause hesitation are:
| Screen | What to choose | Why |
|---|---|---|
| Choosing the default editor used by Git | An editor you’re used to (such as VS Code) | The default, Vim, leaves you stuck figuring out how to quit if you don’t know it |
| Adjusting the name of the initial branch in new repositories | Choose Override the default branch name and enter main | Takes care of the “default branch name” described below right here |
Installation also installs an app called Git Bash. On Windows, type the commands in this guide in Git Bash. Commands written the same way as on macOS and Linux work there as is.
Initial setup: telling Git who is recording#
As you saw in Part 1, #05, a commit includes the author’s name and email address. Git fills these in from the values you set here. If you don’t set them, your first commit will stop with Please tell me who you are., or values guessed from your PC’s name will be used without asking.
git config --global user.name "Taro Yamada"
git config --global user.email "[email protected]"user.name: the name recorded in history. It doesn’t have to be your real name. Using plain ASCII letters avoids garbled text in any environmentuser.email: the email address recorded in history. The value you enter here becomes readable by anyone once you publish your commits
If there’s an address you don’t want public, it’s safe to use the noreply address you noted in Part 1, #04 (Creating a GitHub Account).
--global means “apply this to my whole user account on this PC.” Once set, it’s used in every repository you create from now on.
Make main the default branch name#
git config --global init.defaultBranch mainAs covered in Part 1, #05, a branch is a named pointer to a commit. When you create a repository, a single first branch is set up automatically. In Git as of October 2026 (2.x), that branch is named master unless you configure otherwise.
Using main is now the norm, and this guide uses main too. Git 3.0 is expected to change the default to main, but until then, this one line keeps things consistent.
Set your editor (optional)#
When you write a commit message, Git may open an editor (covered in Part 2, #09). If you use VS Code, set it like this.
git config --global core.editor "code --wait"--wait tells Git to “wait until the editor tab is closed.” Without it, Git moves on before you’ve written the message. If you’re told the code command can’t be found, you can skip this setting.
Check your settings#
git config --global --list
# Output (example):
# user.name=Taro Yamada
# [email protected]
# init.defaultbranch=mainTo see a single value, add the key name.
git config user.email
# Output:
# [email protected]Where are settings stored?#
git config settings are written to plain text files. There are three levels of storage, depending on scope.
| Option | Scope | Stored in |
|---|---|---|
--system | All users on this PC | etc/gitconfig in Git’s install location |
--global | All repositories for your user | .gitconfig in your home folder |
--local (default) | That repository only | .git/config inside the repository |
If the same setting exists at multiple levels, the narrower scope wins. For example, to use a different email address only in a work repository, run git config user.email inside that repository without --global.
If you lose track of which file’s value is in effect, add --show-origin to also display where each value is stored.
git config --list --show-originCreate a practice folder#
In Part 2, you’ll work hands-on in a practice folder that’s fine to break. Create one under your home folder.
mkdir ~/git-practice
cd ~/git-practice~ is the symbol for your home folder. On the next page, you’ll turn this folder into a repository.
FAQ#
Q. Do I need to “register an account” for Git?
A. No. Git is software that runs on your local PC, and user.name and user.email are like a signature attached to your records. They aren’t registered anywhere.
Summary#
- How to install Git differs by OS. If
git --versionshows a number, you’re ready - On Windows, Git Bash lets the same commands as on macOS and Linux work as is
user.nameanduser.emailare written into commits and readable by anyone once publishedinit.defaultBranch mainmakes the first branch namemain- Settings have three levels —
--system,--globaland--local— and the narrowest scope wins
Next page#
07. Creating a Repository (git init) — Run git init in the practice folder you just made and watch an ordinary folder become a repository.