# Set up Git

## Install Git

Download Git from [git-scm.com/install](https://git-scm.com/install/) and run the installer. Git for Windows includes Git Bash: use that terminal for every command here. If your editor has Git built in, it runs the same commands under its interface.

```bash
git --version
```

## Tell Git who you are

Git records this identity on every commit you make.

```bash
git config --global user.name "Alex Example"
git config --global user.email "alex@example.com"
```

## Three defaults

```bash
git config --global init.defaultBranch main
```

This names the first branch of a new repository `main` instead of `master`.

```bash
git config --global pull.rebase true
```

Without this, pulling your own branch after pushing from two machines creates a commit titled something like "Merge branch 'add-login' of codebahn.net into add-login". Rebasing on pull avoids it.

```bash
git config --global push.autoSetupRemote true
```

With this set, `git push` works on a new branch without typing `-u origin <branch>` first.

## Check

```bash
git config --global --list
```

:::note[On Codebahn]
Add your SSH key before your first push: [Getting started, step 3](/docs/getting-started/#3-push-your-first-repository-5-min).
:::

Git basics is licensed under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/): copy it, adapt it, keep the credit.
