Dela via


Install and set up Git

Git isn't yet a default option on computers, so it must be manually installed and configured. And like other software, it's important to keep Git up to date. Updates protect from security vulnerabilities, fix bugs, and provide access to new features.

The following sections describe how to install and maintain Git for the three major platforms.

Install Git for Windows

Download and install Git for Windows. Once installed, Git is available from the command prompt or PowerShell. It's recommended that you select the defaults during installation unless there's good reason to change them.

Git for Windows doesn't automatically update. To update Git for Windows, download the new version of the installer, which updates Git for Windows in place and retains all settings.

Install Git for macOS

macOS 10.9 (Mavericks) and higher installs Git the first time you attempt to run it from the Terminal. While this method is an easy way to get Git on a system, it doesn't allow for control over how often updates or security fixes are applied.

Instead, it's recommended that you install Git through Homebrew and that you use Homebrew tools to keep Git up to date. Homebrew is a great way to install and manage open source development tools on a Mac from the command line.

Install Homebrew and run the following to install the latest version of Git on a Mac:

> brew install git

To update the Git install, use Homebrew's upgrade option:

> brew upgrade git

A graphical installer for Git on macOS is also available from the official Git website.

Install Git for Linux

Use the Linux distribution's native package management system to install and update Git. For example, on Ubuntu:

> sudo apt-get install git

Configure Git on Linux

Set up the name and email address before starting to work with Git. Git attaches this information to changes and lets others identify which changes belong to which authors.

Run the following commands from the command prompt after installing Git to configure this information:

> git config --global user.name "<First_name> <Last_name>"

> git config --global user.email "<user_email_address>"

Visual Studio offers a great out-of-the-box Git experience without any extra tooling. Learn more in this Visual Studio Git tutorial.