How to install Git on Windows, macOS, or Linux?

To install Git on Windows, macOS, or Linux, follow these steps:

Windows:

  1. Visit the official Git website (https://git-scm.com/) and download the latest version of Git for Windows.
  2. Run the downloaded installer.
  3. Select the desired installation options and click "Next" throughout the installation process.
  4. On the "Choose the default editor used by Git" screen, select your preferred text editor or choose the default option.
  5. On the "Adjusting your PATH environment" screen, select the second option ("Git from the command line and also from 3rd-party software") and click "Next".
  6. Choose the desired HTTPS transport backend on the "Configuring the line ending conversions" screen and click "Next".
  7. On the "Configuring the terminal emulator to use with Git Bash" screen, choose your preferred terminal emulator or select the default option.
  8. Keep the remaining options as default and complete the installation process.
  9. Open the command prompt and type "git --version" to verify that Git has been successfully installed.

macOS:

  1. Open the Terminal application by going to "Applications" > "Utilities" > "Terminal".
  2. Check if Git is already installed by entering the command "git --version". If it is not installed, continue to the next step.
  3. Install Xcode Command Line Tools by entering the command "xcode-select --install" and following the prompts.
  4. Install Homebrew, a package manager for macOS, by visiting the Homebrew website (https://brew.sh/) and following the installation instructions.
  5. Once Homebrew is installed, type the command "brew install git" to install Git.
  6. After the installation is complete, verify that Git is installed by typing "git --version" in the terminal.

Linux (Ubuntu):

  1. Open the terminal by pressing Ctrl+Alt+T.
  2. Update the package list by entering the command "sudo apt update && sudo apt upgrade".
  3. Install Git by typing "sudo apt install git".
  4. Once the installation is complete, verify that Git is installed by typing "git --version" in the terminal.

Note: For other Linux distributions, use their respective package manager to install Git (e.g., "yum" for Fedora, "dnf" for openSUSE, "pacman" for Arch Linux).

After successfully installing Git, you can configure it with your name and email by running the following commands in the terminal or command prompt:

  • git config --global user.name "Your Name"
  • git config --global user.email "[email protected]"