1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
|
---
stage: Create
group: Source Code
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://handbook.gitlab.com/handbook/product/ux/technical-writing/#assignments
description: "How to install Git on your local machine."
---
# Install Git
To contribute to GitLab projects, you must download and install the Git client on your local machine.
This page explains how to install and configure Git on macOS and Ubuntu Linux.
For information on downloading and installing Git on other operating systems, see the
[official Git website](https://git-scm.com/downloads).
After you install and configure Git, [generate and add an SSH key pair](../../../user/ssh.md#generate-an-ssh-key-pair)
to your GitLab account. GitLab uses the SSH protocol to securely communicate with Git.
With SSH, you can authenticate to the GitLab remote server without entering your username and password each time.
## Install and update Git
::Tabs
:::TabTitle macOS
Though a version of Git is supplied by macOS, you should install the latest version of Git. A common way to
install Git is with [Homebrew](https://brew.sh/index.html).
To install the latest version of Git on macOS with Homebrew:
1. If you've never installed Homebrew before, follow the
[Homebrew installation instructions](https://brew.sh/index.html).
1. In a terminal, install Git by running `brew install git`.
1. Verify that Git works on your local machine:
```shell
git --version
```
Keep Git up to date by periodically running the following command:
```shell
brew update && brew upgrade git
```
:::TabTitle Ubuntu Linux
Though a version of Git is supplied by Ubuntu, you should install the latest version of Git. The latest version is
available using a Personal Package Archive (PPA).
To install the latest version of Git on Ubuntu Linux with a PPA:
1. In a terminal, configure the required PPA, update the list of Ubuntu packages, and install `git`:
```shell
sudo apt-add-repository ppa:git-core/ppa
sudo apt-get update
sudo apt-get install git
```
1. Verify that Git works on your local machine:
```shell
git --version
```
Keep Git up to date by periodically running the following command:
```shell
sudo apt-get update && sudo apt-get install git
```
::EndTabs
## Configure Git
To start using Git from your local machine, you must enter your credentials
to identify yourself as the author of your work.
You can configure your Git identity locally or globally:
- Locally: Use for the current project only.
- Globally: Use for all current and future projects.
::Tabs
:::TabTitle Local setup
Configure your Git identity locally to use it for the current project only.
The full name and email address should match the ones you use in GitLab.
1. In your terminal, add your full name. For example:
```shell
git config --local user.name "Alex Smith"
```
1. Add your email address. For example:
```shell
git config --local user.email "your_email_address@example.com"
```
1. To check the configuration, run:
```shell
git config --local --list
```
:::TabTitle Global setup
Configure your Git identity globally to use it for all current and future projects on your machine.
The full name and email address should match the ones you use in GitLab.
1. In your terminal, add your full name. For example:
```shell
git config --global user.name "Sidney Jones"
```
1. Add your email address. For example:
```shell
git config --global user.email "your_email_address@example.com"
```
1. To check the configuration, run:
```shell
git config --global --list
```
::EndTabs
### Check Git configuration settings
To check your configured Git settings, run:
```shell
git config user.name && git config user.email
```
## Related topics
- [Git configuration documentation](https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration)
- [Use SSH keys to communicate with GitLab](../../../user/ssh.md)
|