Before using Git commands, you need to install Git on your computer. Git is available for major operating systems such as Windows, macOS and Linux.
git --version in a terminal.
Git installation means installing the Git software on your computer so that you can use Git commands to manage your projects.
After installation, Git can be used from a terminal such as Git Bash, Command Prompt or another supported shell.
Git can be installed on several operating systems, including:
The installation process differs slightly depending on the operating system.
Windows users can install Git using the official Git for Windows installer.
The installer provides Git along with tools such as Git Bash.
To install Git on Windows, download the Git for Windows installer from the official Git website.
Choose the installer appropriate for your Windows system and processor architecture.
After downloading the installer, open the installer file. The Git Setup window will guide you through the installation process.
Follow the setup instructions shown on the screen.
The installer asks where Git should be installed. For most beginners, the default installation folder is suitable.
You can continue with the default location unless you have a specific reason to change it.
The Git installer provides options for selecting components and features.
Beginners can generally use the recommended defaults and continue through the setup wizard.
Git for Windows includes Git Bash, a terminal environment that allows you to run Git commands.
git --version
Git Bash can also be used for many common command-line operations.
Git commands can be executed from a command-line interface. For example:
git status
The command-line interface is useful for learning and automating Git workflows.
Continue through the installer until the installation is complete. After the installation finishes, open a terminal and verify Git.
git --version
The git --version command displays the installed Git version.
git --version
A successful installation should display a Git version number.
The exact version depends on the Git release installed on your computer. An example format is:
git version 2.x.x
The version number may be different on your system.
Git can be installed and used on macOS. Depending on the system configuration, Git may already be available or can be installed using an appropriate Git installation method.
After installation, verify it with:
git --version
Git can be installed using the package manager provided by your Linux distribution.
For example, Debian-based systems commonly use:
sudo apt install git
The exact command can vary between Linux distributions.
After installing Git, verify the installation using:
git --version
If Git is installed correctly, the terminal will display the installed version.
The system's PATH helps the terminal find executable programs.
A properly configured Git installation should allow you to run
the git command from a terminal.
git --version
The Git executable is the program that runs Git commands. When you type:
git status
the operating system finds and executes the Git program.
On Windows, after installing Git, you can open Git Bash from the Start menu or from a project folder where the option is available.
Then you can execute Git commands directly:
git --version
git status
Git commands can also be used from other terminal applications, provided Git is correctly installed and available through the system PATH.
git --version
A simple installation test is to run:
git --version
You can then test a basic Git command:
git help
If the commands execute successfully, Git is available from the terminal.
After installing Git, create a folder for practicing Git commands. For example:
mkdir git-practice
cd git-practice
You can initialize this folder as a Git repository in the next step.
Inside your practice folder, initialize a Git repository:
git init
Git will create the repository metadata for the project.
After initializing the repository, check its status:
git status
This confirms that Git can operate in the current project directory.
Sometimes the terminal may display an error such as:
'git' is not recognized as an internal or external command
This generally means Git is not installed correctly or the Git executable is not available through the system PATH.
If the git command is not recognized, check whether
Git was installed correctly and whether its executable directory
is available through the PATH.
On Windows, restarting the terminal after installation can also be necessary for newly updated environment settings to become available.
If Git installation is incomplete or damaged, reinstalling Git using the appropriate installer can help resolve installation problems.
After reinstalling, verify it again:
git --version
Git is actively maintained and new releases are published over time. Keeping Git reasonably up to date can provide newer features and bug fixes.
The update method depends on your operating system and installation method.
git --version.git init.git status.After installing Git, you can perform this simple test:
git --version
mkdir git-practice
cd git-practice
git init
git status
This confirms that Git is available and can initialize a repository.
Once Git is installed and verified, you are ready to learn Git configuration, repositories, commits, branches and other commands.
In the next lesson, we will learn how to configure Git with your name and email address.
Question: Which command is used to check whether Git is installed?