Setting up Git on Different Platforms

Git is a distributed version control system that allows you to track changes and collaborate on projects

In order to start using Git, you need to set it up on your preferred platform. This chapter will guide you through the installation process on Windows, macOS, and Linux.

Additionally, we will cover the configuration of Git with user details and introduce both the Git command line interface (CLI) and graphical user interfaces (GUIs).


Installation instructions for Windows

Download Git:

  • Visit the official Git website: https://git-scm.com

  • Click on the "Downloads" link.

  • This will automatically detect your operating system and provide the download link for the latest version of Git for Windows.

  • Click the download link to start the download.

Run the installer:

  • Once the download is complete, locate the downloaded file (e.g., Git-x.x.xx-64-bit.exe).

  • Double-click the file to run the installer.

  • If prompted by User Account Control, click "Yes" to allow the installation.

Customise the installation:

  • The installer will provide you with various options during the installation process.

  • It is recommended to stick with the default options unless you have specific requirements.

  • Ensure that the "Git Bash Here" option is selected, as it will be useful for working with Git through the command line.

Complete the installation:

  • Follow the prompts and click "Next" to proceed through the installation process.

  • When you reach the "Adjusting your PATH environment" screen, select the option "Git from the command line and also from 3rd-party software."

  • Leave the other options as they are unless you have a specific need to modify them.

  • Click "Next" to continue.

  • On the next screen, select the desired text editor for Git. You can choose the default editor or any other editor of your preference.

  • Click "Next" and then "Install" to begin the installation process.

  • Once the installation is complete, click "Finish" to exit the installer.

Verify the installation:

  • Open the command prompt or Git Bash.

  • Type the following command to check if Git is installed and properly configured:

git --version
  • If Git is installed correctly, it will display the installed version.


Installation instructions for macOS

Homebrew installation (recommended):

  • Open the Terminal application. You can find it in the "Utilities" folder within the "Applications" folder.

  • Run the following command to install Homebrew, a package manager for macOS:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  • Follow the instructions provided by the installer.

Git installation:

  • Once Homebrew is installed, you can use it to install Git by running the following command

brew install git
  • Homebrew will handle the installation and set up Git on your macOS system.

Verify the installation:

  • Open the Terminal.

  • Type the following command to check if Git is installed and properly configured:

git --version
  • If Git is installed correctly, it will display the installed version.


Installation instructions for Linux

Package manager installation:

  • Different Linux distributions have different package managers.

  • Use the appropriate package manager for your distribution to install Git.

  • For example, on Ubuntu or Debian-based systems, you can use the following command:

sudo apt-get update
sudo apt-get install git

Verify the installation:

  • Open the terminal.

  • Type the following command to check if Git is installed and properly configured:

git --version
  • If Git is installed correctly, it will display the installed version.


Configuring Git with user details

Once Git is installed, it is essential to configure it with your user details. This information is used to identify the author of the commits you make.

To configure Git with your user details, open the command line or terminal and execute the following commands, replacing the placeholders with your actual name and email address:

git config --global user.name "Your Name"
git config --global user.email "youremail@example.com"

The --global flag sets the configuration globally for your user account. If you want to override these settings for a specific project, you can navigate to the project directory and omit the --global flag when running the commands.

Introduction to Git command line interface (CLI) and graphical user interfaces (GUIs):

Git provides two primary ways to interact with the version control system: through the command line interface (CLI) and graphical user interfaces (GUIs).

The CLI offers a powerful and flexible way to work with Git, providing access to all Git commands and options. It is especially useful for advanced usage, automation, and scripting. You can open the command prompt or terminal and use Git commands directly.

On the other hand, Git GUIs provide a more user-friendly and visual representation of Git's functionality. They often include features like commit history visualisation, branch management, and conflict resolution tools. Several popular Git GUIs are available, including:

Git GUIs can be helpful for beginners or users who prefer a visual interface for working with Git.

It's important to note that the CLI and GUIs are complementary, and you can choose the approach that best suits your workflow and preferences. Both methods provide access to the same underlying Git functionality.

With Git properly installed, configured, and an understanding of the available interfaces, you are now ready to start using Git for version control.

Last updated