Git installation
Install and setup git
Last updated: 2/11/2025
Git installation
Git is available for Windows, macOS, and Linux, and the installation process is relatively simple on each platform.
For Windows:
Step 1: Download Git
- Go to the official Git website: https://git-scm.com/.
- Click the "Download" button for Windows. The website will automatically detect your operating system and provide the appropriate download link.
Step 2: Run the Installer
- Once the download is complete, run the installer.
- Follow the installation wizard. You can use the default settings for most of the prompts, but be sure to take note of the following important options:
- Choosing the default editor: When prompted, select your preferred text editor. For beginners, it's recommended to choose the default (Vim) or another editor like Notepad++.
- Adjusting your PATH environment: Choose "Use Git from the command line and also from 3rd-party software". This option will make Git available in your system’s PATH, allowing you to run Git commands from the command prompt.
- HTTPS transport backend: Choose the default option “Use the OpenSSL library,” which is recommended for most users.
Step 3: Verify the Installation
-
After the installation is complete, open the Command Prompt (search for
cmd
in the Start menu). -
Type the following command to check if Git was installed successfully:
git --version
If Git is installed correctly, you should see the Git version printed in the terminal (e.g.,
git version 2.34.1.windows.1
).
For macOS:
Step 1: Install Git via Homebrew (Recommended)
-
Open the Terminal application (you can find it by searching for "Terminal" in Spotlight).
-
First, check if you have Homebrew installed by typing:
brew --version
If Homebrew is installed, it will show the version number. If it's not installed, you can install it by running:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
-
Once Homebrew is installed, install Git by running:
brew install git
Step 2: Verify the Installation
-
After the installation is complete, check if Git was installed successfully by typing:
git --version
You should see the Git version printed in the terminal (e.g.,
git version 2.34.1
).
For Linux:
Step 1: Install Git via Package Manager
On Linux, the process of installing Git will vary depending on your distribution. Below are the commands for some common distributions:
Ubuntu/Debian
-
Open your terminal.
-
Run the following command to update your package list:
sudo apt update
-
Install Git using the following command:
sudo apt install git
Fedora
-
Open your terminal.
-
Install Git with:
sudo dnf install git
CentOS/RHEL
-
Open your terminal.
-
Run the following command to install Git:
sudo yum install git
Step 2: Verify the Installation
After installation, you can verify that Git is installed by running:
git --version
You should see the Git version printed in the terminal (e.g., git version 2.34.1
).
Configuring Git
After installing Git, it is important to configure your identity. This helps Git associate your commits with your name and email address.
Step 1: Set Your Name and Email
Run the following commands in your terminal, replacing Your Name
and your_email@example.com
with your actual name and email address:
git config --global user.name "Your Name" git config --global user.email "your_email@example.com"
Step 2: Verify Your Configuration
To check that your configuration was set correctly, you can run:
git config --list
This will display all the configuration options, including your name and email.
Conclusion
Now that you have installed and configured Git on your system, you’re ready to start using it for version control. In the next lesson, we’ll cover how to create a new Git repository, initialize it, and start tracking your code changes.