[Git Series Part 2] Installation and Basic Setup

한국어 버전

Install Git and Set the Basics

This post is for a beginner Mac user following the Git series step by step. You will install Git with Homebrew, save your name and email, and check that your terminal is using the version you just installed.

What We Will Do

  • Install Git through Homebrew
  • Confirm that the Homebrew version is active
  • Configure your username and email
  • Add two beginner-friendly defaults
  • Verify that the settings are saved

Before You Start

Required:

  • iTerm2
  • Homebrew
  • Your name and email address

Time needed: About 5 minutes

Previous guide: Git Series Part 1: What is Git?

Why use Homebrew Git?

macOS can already include Git, but that version is usually tied to Apple's developer tools. In this series, we use the Homebrew version so updates stay predictable and later troubleshooting stays consistent.

If Homebrew is not installed yet

Install Homebrew once, then come back to the Git commands in this post.

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

Step 1: Install Git

Install with Homebrew

Install Git and verify the active binary zsh · ~/workspace
Ready. Press Replay to run the scripted session.

If Git is already installed, Homebrew simply tells you it is up to date.

which git confirms which Git your terminal will actually use. On Apple Silicon Macs, the Homebrew path is usually /opt/homebrew/bin/git. On Intel Macs, it is often /usr/local/bin/git.

💡 Tip: If which git shows /usr/bin/git, your shell is still using the macOS version instead of the Homebrew version.

Step 2: Configure User Info

Git records who made each change, so it needs your user info.

What --global means

The --global flag saves the setting in ~/.gitconfig, so it applies to every Git repository on your Mac. That is the right starting point for most beginners.

Set your name

Store the author name that will appear in commit history.

Set your email

Follow with the email address you want Git to attach to your commits.

Save and verify user info zsh · ~/workspace
Ready. Press Replay to run the scripted session.

If Git prints nothing after a git config command, that usually means the setting was saved correctly.

⚠️ Important: Use the same email you plan to use with GitHub. Later, that email helps GitHub match your commits to your account.

Verify the settings

Use git config --list when you want the full list, and use git config --global user.name or git config --global user.email when you want to check one value quickly.

Step 3: Additional Settings

These two settings are recommended, not mandatory. They make the next posts in the series smoother.

Default editor

Git sometimes opens a text editor when it needs text input, such as a commit message. For beginners, nano is easier to start with than vim.

Default branch name

Set the default branch to main when you create new repositories.

Inspect the config file

Seeing how the settings are stored in the file helps you understand Git’s configuration.

Add recommended defaults zsh · ~/workspace
Ready. Press Replay to run the scripted session.

If you already know vim well, you can use git config --global core.editor vim instead.

Confirm Everything Works

Completion test:

Final setup check zsh · ~/workspace
Ready. Press Replay to run the scripted session.

Key commands:

Command Description
which git Show which Git binary your terminal uses
git --version Check the version
git config --global user.name "Name" Set your name
git config --global user.email "Email" Set your email
git config --global core.editor nano Set a beginner-friendly editor
git config --list Show configured values

Common Mistakes

Mistake 1: "command not found: brew"

Homebrew is not installed yet.

Fix:

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

After that, run:

brew install git

Mistake 2: which git shows /usr/bin/git

Git is installed, but your terminal is still using the macOS version.

Fix:

  • Restart iTerm2 and run which git again.
  • If the result is still /usr/bin/git, check that your shell loads the Homebrew path correctly.

Mistake 3: Settings do not appear to save

Fix:

# Check permissions of ~/.gitconfig
ls -la ~/.gitconfig

# Create the file if it does not exist
touch ~/.gitconfig

# Check one value directly
git config --global user.name

Mistake 4: Need to change the email later

Fix:

git config --global user.email "[email protected]"

Mistake 5: Spaces in the name

Wrong:

git config --global user.name Hong Gildong

Correct:

git config --global user.name "Hong Gildong"

Mistake 6: Undo one setting

Fix:

git config --global --unset user.name
git config --global --unset user.email

If You Reached Here, You Succeeded

Done checklist:

  • Confirmed Homebrew is available
  • Confirmed which git points to the expected Git binary
  • Confirmed git --version
  • Set user.name
  • Set user.email
  • Set a default editor and branch name
  • Checked values with git config --list
  • Peeked inside ~/.gitconfig

Command recap:

brew install git
which git
git --version
git config --global user.name "Hong Gildong"
git config --global user.email "[email protected]"
git config --global core.editor nano
git config --global init.defaultBranch main
git config --list
cat ~/.gitconfig

Why This Matters for the Next Post

You have now told Git which program to use, who you are, and which default branch name to create. In the next post, those settings become visible when you create a repository and make your first commit.

Next in the Series

With installation finished, let’s create a repository and make the first commit.

Git Series Part 3: Initialize, Add, Commit walks through git init, git add, and git commit step by step.

💬 댓글

이 글에 대한 의견을 남겨주세요