Back to Blog
Lesson 2 of the Git & GitHub: Git & GitHub from Zero course
GitJuly 13, 20263 min read

Git Installation: Set Up Your Terminal for Version Control

Get your development environment ready by performing a proper git installation. Learn how to verify your setup via the CLI to start building your projects.

gitterminalcliinstallationdevopsbeginners

Previously in this course, we covered the high-level concepts of version control in our Introduction to Version Control. Now that you understand the "why" behind distributed version control, it is time to transition into the "how" by getting the software running on your machine.

In this lesson, we will perform a proper git installation and ensure your terminal is correctly configured to communicate with the Git binary.

Why the CLI is Your Primary Git Interface

While many code editors (like VS Code or IntelliJ) offer built-in Git buttons, learning to use Git via the CLI (Command Line Interface) is a non-negotiable skill for any serious engineer.

When you use the terminal, you aren't just clicking buttons; you are executing commands that interact directly with the Git engine. This transparency is crucial for debugging complex states—something you'll appreciate once we move into more advanced topics like Git Interactive Rebase later in this course.

Performing the Git Installation

Depending on your operating system, the installation process differs slightly, but the end result is the same: a functional git command available in your PATH.

macOS

The easiest way to install Git on macOS is via Homebrew. If you don't have it, install it from brew.sh. Once installed, run:

Bash
brew install git

Windows

Download the official Git for Windows installer from git-scm.com. Run the installer and keep the default settings, which include "Git Bash"—a terminal emulator that provides a bash-like experience on Windows.

Linux (Ubuntu/Debian)

Open your terminal and update your package list before installing:

Bash
sudo apt update
sudo apt install git

Verifying Your Installation

Once the installation finishes, you need to verify that your system can "see" the Git executable. Open your terminal (or Git Bash on Windows) and type the following:

Bash
git --version

If the installation was successful, you will see an output similar to: git version 2.45.2 (or a newer version).

Practice Exercise

To ensure your environment is ready for the upcoming lessons, perform these two steps:

  1. Open your terminal.
  2. Run git --version. If you see a version number, you've successfully installed Git. If you get a "command not found" error, try closing and reopening your terminal to refresh your PATH variables.

Common Pitfalls

Even simple installations can go wrong. Here is what to watch out for:

  • PATH Issues: If your terminal says command not found after a successful install, your system doesn't know where the Git binary is located. On Windows, ensure you selected the option to "Git from the command line and also from 3rd-party software" during installation.
  • Version Mismatch: Sometimes, your computer might come with a pre-installed, outdated version of Git. If git --version shows something ancient (like version 1.x), you may need to explicitly update your PATH to prioritize the newer version you just installed.
  • Terminal Confusion: On Windows, avoid using the default Command Prompt (cmd.exe) if possible. Use Git Bash or PowerShell to ensure you have a modern environment that handles Unix-style commands effectively.

FAQ

Do I need to be an expert in the terminal to use Git? No. You only need to learn a handful of commands to start, which we will cover in the next few lessons.

Does Git work differently on Windows vs. macOS? The core functionality is identical. The only difference is the terminal shell you use to interact with it.

Can I use a GUI instead of the terminal? You can, but I strongly advise against it for beginners. Using the CLI forces you to understand what is happening under the hood, which is essential for troubleshooting.

Recap

We have successfully installed Git and verified it via the CLI. You now have a working environment, which is the foundational step for all professional development workflows, including those you might see in Setting Up the Local Development Environment for PHP or similar platform-specific guides.

Up next: We will configure your identity so that Git knows who is making changes to your code.

Similar Posts