How to install Git on any OS
Git can be installed on the most common operating systems like Windows, Mac, and Linux. In fact, Git comes installed by default on most Mac and Linux machines!
To see if you already have Git installed, open up your terminal application.
Once you’ve opened your terminal application, type
git version
. The output will either tell you which version of
Git is installed, or it will alert you that git
is an unknown
command. If it’s an unknown command, read further and find out how to
install Git.
Installing GitHub Desktop will also install the latest version of Git if you don’t already have it. With GitHub Desktop, you get a command-line version of Git with a robust GUI. Regardless of if you have Git installed or not, GitHub Desktop offers a simple collaboration tool for Git. You can learn more here.
git version
to verify Git was installed.
Note:
git-scm
is a
popular and recommended resource for downloading Git for Windows. The
advantage of downloading Git from git-scm
is that your
download automatically starts with the latest version of Git included with
the recommended command prompt, Git Bash
. The download
source is the same
Git for Windows installer as
referenced in the steps above.
GitHub integration is provided through the GitHub Pull Requests and Issues extension. To get started with the GitHub in VS Code, you’ll need to create an account and install the GitHub Pull Requests and Issues extension. Once you’ve installed the GitHub Pull Requests and Issues extension, you’ll need to sign in. Follow the prompts to authenticate with GitHub and return to VS Code.
Note: You can perform actions like, you can search for and clone a repository from GitHub using the Git: Clone command in the Command Palette (Ctrl+Shift+P) or by using the Clone Repository button in the Source Control view (available when you have no folder open). Learn more here
Most versions of MacOS will already have Git
installed, and
you can activate it through the terminal with git version
.
However, if you don’t have Git installed for whatever reason, you can
install the latest version of Git using one of several popular methods as
listed below:
git version
to
verify Git was installed.
Note:
git-scm
is a
popular and recommended resource for downloading Git on a Mac. The
advantage of downloading Git from git-scm
is that your
download automatically starts with the latest version of Git. The download
source is the same
macOS Git Installer
as referenced in the steps above.
Homebrew is a popular package manager for macOS. If you already have Homebrew installed, you can follow the below steps to install Git:
brew install git
.
git version
.
Fun fact: Git was originally developed to version the Linux operating system! So, it only makes sense that it is easy to configure to run on Linux.
You can install Git
on Linux through the package management
tool that comes with your distribution.
apt
.sudo apt-get update
.
sudo apt-get install git-all
.
git version
.
dnf
.sudo dnf install git-all
.
git version
.
Note: You can download the proper Git versions and read more about how to install on specific Linux systems, like installing Git on Ubuntu or Fedora, in git-scm’s documentation.
Looking to install Git via the source code? Learn more here.