Git Installation

4 min

Table of contents

  1. Introduction
  2. Installation on Windows
  3. Installation on Ubuntu
  4. Installation on macOS
  5. Configuring Git
  6. Conclusion
  7. Reference

Introduction


Git is a distributed version control system that lets you track changes in the source code on your local machine.

⬆️ Back to table of contents


1-Steps to install Git on Windows


Step 1: Download Git

  1. Go to the official Git site: git-scm.com.
  2. Click the "Download for Windows" button.
  3. Select the 64-bit version of Git for Windows and start the download.

Step 2: Installing Git

  1. Once the file is downloaded, open it to start the installation.
  2. Follow the installer instructions and accept the default settings, unless you have specific requirements.

https://phoenixnap.com/kb/how-to-install-git-windows

Step 3: Checking the Git Bash installation

  • After the installation, you should see the Git Bash option in your context menu (right-click on your desktop or in a directory).
  • Git Bash is a command-line interface that lets you run Git commands.

Step 4: Verify the Git installation

  • Open the command prompt (cmd) or Git Bash.
  • Type the following command to check that Git is correctly installed:
    git --version
  • If the installation succeeded, you will see the installed Git version displayed, for example: git version 2.34.1.

⬆️ Back to table of contents


2-Installation on Ubuntu


Step 1: Download Git

  1. Consult the official Git site to check the installation steps specific to Ubuntu: git-scm.com.
  2. Log in to your Ubuntu system.

Step 2: Uninstall an older version of Git (if needed)

  • Before installing the latest version of Git, it is recommended to uninstall any older version already present. Run the following command:
    apt update
    apt git --version
    sudo apt purge git -y

Step 3: Install the latest version of Git

  1. Add the PPA repository for Git:
    sudo add-apt-repository ppa:git-core/ppa
  2. Update the package list:
    sudo apt update
  3. Install Git:
    sudo apt install git -y

Step 4: Verify the Git installation

  • After the installation, check that Git is properly installed by running:
    git --version
  • This should display the installed Git version, for example: git version 2.34.1.

⬆️ Back to table of contents


3-Installation on macOS


Step 1: Install Homebrew (if needed)

  • If you have not yet installed Homebrew (a package manager for macOS), you can install it by running the following command in your terminal:
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Step 2: Install Git via Homebrew

  • Once Homebrew is installed, install Git by running the following command:
    brew install git

Step 3: Verify the Git installation

  • Check that Git is installed by typing in your terminal:
    git --version
  • If the installation succeeded, the installed Git version will be displayed.

⬆️ Back to table of contents


4-Configuring Git after installation


After installing Git on any operating system, you need to configure it for the first time.

Step 1: Configure the user name

  • Enter the following command to configure your user name (which will appear in every commit you make):
    git config --global user.name "Votre Nom"

Step 2: Configure the email address

  • Configure the email address that will be associated with your commits:
    git config --global user.email "votre.email@example.com"

Step 3: Verify the Git configuration

  • To check all your current Git configurations, run:
    git config --list

⬆️ Back to table of contents


Conclusion


  • Git is an essential tool for tracking changes in source code and makes collaboration between developers easier. After following the steps above for installation on Windows, Ubuntu, or macOS, you can now start using Git to manage your projects effectively. It is also important to configure Git correctly after installation to ensure a good trace of contributions.

  • This lesson covers the basics of installing Git on different operating systems. Make sure you configure Git properly for optimal use in your projects, then verify with git --version and git config --list.


⬆️ Back to table of contents

Reference:

⬆️ Back to table of contents