Welcome to your very first steps with Git! Before we can start tracking changes, collaborating, and enjoying all the power of version control, we need to get Git installed on your machine. Don't worry, it's a straightforward process, and we'll guide you through it. Git is available for Windows, macOS, and Linux, so no matter your operating system, you're covered.
The easiest way to install Git is by downloading the installer directly from the official Git website. This ensures you get the latest stable version and all necessary components.
- Visit the Official Git Website: Open your web browser and go to https://git-scm.com/downloads.
- Download the Installer: Click on the download link for Windows. This will download an executable file (e.g.,
Git-2.x.x-64-bit.exe). - Run the Installer: Once the download is complete, double-click the executable file to start the installation wizard.
- Follow the Prompts: The installer is very user-friendly. For most beginners, the default settings are perfectly fine. You can usually click 'Next' through most of the screens. Key decisions you might encounter include:
- Choosing a Text Editor: Git needs a text editor for commit messages. You can select your preferred editor (like VS Code, Notepad++, or even the default Vim if you're adventurous!). If you're unsure, the default is usually a safe bet.
- Adjusting Your PATH Environment: This setting determines how you'll access Git from your command line. The recommended option ('Git from the command line and also from 3rd-party software') is generally best.
- Complete Installation: Click 'Install' and then 'Finish' once the process is done.
-
Official Website: Navigate to https://git-scm.com/downloads.
-
Download for macOS: Click on the macOS download link. You'll download a
.pkginstaller. -
Run the Installer: Double-click the downloaded
.pkgfile. -
Follow the Wizard: Similar to Windows, the macOS installer is straightforward. Click 'Continue' and 'Agree' to the license. Accept the default installation location unless you have a specific reason to change it.
-
Alternative: Homebrew: If you're comfortable with the command line and already have Homebrew (a package manager for macOS) installed, you can install Git using a single command: bash brew install git
If you don't have Homebrew, you can install it from https://brew.sh/.
Most Linux distributions come with Git pre-installed or readily available in their package repositories. You'll typically use your distribution's package manager to install it.
For Debian/Ubuntu-based systems: bash sudo apt update sudo apt install git
For Fedora-based systems: bash sudo dnf install git
For Arch Linux: bash sudo pacman -S git
Once you've completed the installation, it's crucial to verify that Git is installed correctly and accessible from your command line (Terminal on macOS/Linux, Command Prompt or Git Bash on Windows). Open your command line interface and type the following command:
git --versionIf Git is installed successfully, you'll see output similar to this (the version number will likely be different):
git version 2.34.1
If you get an error like 'command not found,' double-check that you followed the installation steps carefully and that Git was added to your system's PATH (usually handled by default during installation).
Congratulations! You've successfully installed Git. In the next section, we'll configure Git with your name and email address, which is essential for identifying your contributions.