Setting Up Git

Before you can use Git, you need to install it and tell it who you are. Don’t worry—this is a one-time setup that takes just a few minutes.

Want to master Git configuration? Our Git Configuration guide provides a complete reference for customizing Git’s behavior beyond these basics.

Installing Git

macOS: Git comes pre-installed on macOS, but it’s often an older version. Install the latest via Homebrew:

brew install git

Windows: Download the installer from git-scm.com. During installation, accept the defaults unless you have specific preferences.

Linux: Use your distribution’s package manager:

# Debian/Ubuntu
sudo apt-get install git

# Fedora
sudo dnf install git

# Arch
sudo pacman -S git

Verify the installation:

git --version

Your Identity: Who Are You?

Every change you make with Git is signed with your name and email. Think of it as your signature on a document—it identifies your work and lets others contact you if needed.

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

The --global flag means this applies to all your Git repositories. You only need to do this once per computer.

Verify your setup:

git config user.name
git config user.email

Privacy note: Your email will be visible in your commits. If you’re using GitHub or GitLab and want privacy, use their no-reply email address (find it in your account settings).

Choosing an Editor

Git opens a text editor when you write commit messages or resolve conflicts. By default, this might be vim—a powerful but intimidating editor if you’re not familiar with it.

You can set it to something friendlier:

# Visual Studio Code (most popular)
git config --global core.editor "code --wait"

# Sublime Text
git config --global core.editor "subl -n -w"

# Nano (simple, terminal-based)
git config --global core.editor "nano"

The --wait flag tells Git to wait until you close the editor before continuing. Without it, Git might move on before you’ve finished typing.

Making Push Easier

When you’re ready to share your work, you’ll push it to a remote repository. By default, you need to specify exactly where it should go. This setting makes Git smarter:

git config --global push.autoSetupRemote true

Note: This setting requires Git 2.37+ (released June 2022). On older versions, you’ll need to use git push -u origin <branch-name> the first time you push each branch.

Now Git will automatically figure out where to push your branches. One less thing to remember.

Your Setup Checklist

Verify everything is configured:

git config --list

You should see your name, email, editor, and the other settings we configured. If something’s missing, scroll back up and run that configuration command again.

What’s Next?

With Git installed and configured, you’re ready to create your first repository. This is where the real fun begins—tracking your code, making changes, and never losing work again.

The command line might feel unfamiliar right now, but here’s the thing: every command you learn is a tool you’ll use for the rest of your development career. GUI tools hide these commands behind buttons, which means you never truly understand what’s happening.

By learning the commands, you’re learning how Git actually works—and that knowledge transfers to any team, any project, anywhere.