Table of contents
Introduction
Installation on Windows
Installation on Ubuntu
Installation on macOS
Configuring Git
Conclusion
Reference
Introduction
Git is a distributed version control system that lets you track changes in the source code on your local machine.
1-Steps to install Git on Windows
Step 1: Download Git
Go to the official Git site: git-scm.com .
Click the "Download for Windows" button.
Select the 64-bit version of Git for Windows and start the download.
Step 2: Installing Git
Once the file is downloaded, open it to start the installation.
Follow the installer instructions and accept the default settings, unless you have specific requirements.
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.
2-Installation on Ubuntu
Step 1: Download Git
Consult the official Git site to check the installation steps specific to Ubuntu: git-scm.com .
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
Add the PPA repository for Git:
sudo add-apt-repository ppa:git-core/ppa
Update the package list:
sudo apt update
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.
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.
4-Configuring Git after installation
After installing Git on any operating system, you need to configure it for the first time.
Enter the following command to configure your user name (which will appear in every commit you make):
git config --global user.name "Votre Nom"
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
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.
Reference: