Git & GitHub ยท Chapter 2 of 42

Installing Git

Before using Git, you need to install it on your computer. Git is available for Windows, macOS, and Linux, and installation is quick using official installers or package managers.

Once installed, you can confirm Git works by checking its version from the command line. Most developers use Git entirely through the terminal, though graphical clients also exist.

Syntax
git --version

Installing on each OS

On Windows, download Git for Windows from git-scm.com. On macOS, run `xcode-select --install` or use Homebrew with `brew install git`. On Linux, use your package manager, such as `sudo apt install git` on Ubuntu/Debian.

Verifying installation

After installing, open a terminal and run `git --version`. If Git is installed correctly, it prints the version number instead of an error.

Example 1 (bash)
sudo apt install git
Output
Setting up git (1:2.43.0-1) ...

Installs Git on a Debian/Ubuntu based Linux system.

Example 2 (bash)
git --version
Output
git version 2.43.0

Confirms Git was installed successfully by printing its version.

Key points

  • Git works on Windows, macOS, and Linux.
  • Package managers like apt, brew, and the official installer all work.
  • git --version confirms a successful installation.
  • Most Git usage happens from the command line.
๐Ÿ’ก Note: If `git` is not recognized after installing, you may need to restart your terminal or add Git to your system PATH.

๐Ÿ“ Quick Quiz

1. Which command checks if Git is installed?

2. Which command installs Git on Ubuntu?

3. Where does most Git usage happen?