# How to set GitHub credentials for macOS

> Learn how to set up GitHub authentication on macOS for the git command line and VS Code by installing the gh CLI with Homebrew and running gh auth login.

Author: [Flavio Copes](https://flaviocopes.com/about/) | Published: 2021-11-21 | Topics: [Git](https://flaviocopes.com/tags/git/) | Canonical: https://flaviocopes.com/setup-github-credentials-macos/

Set up [GitHub](https://flaviocopes.com/github/) authentication so you can use it from VS Code or the command line.

I normally use the GitHub Desktop app to interact with my GitHub account, the only place I use for [Git](https://flaviocopes.com/git/) repositories for all my code and websites.

But there are times you need to use the `git` command line, or perhaps the Git integration in VS Code.

Without these steps, you'd get an authentication issue if you try.

Let's set it up.

I assume you have Homebrew installed.

From the command line, run:

```
brew install gh
```

and then use the `gh` tool:

```
gh auth login
```

Then answer a few questions.

![Terminal showing gh auth login command with GitHub.com account selection highlighted](https://flaviocopes.com/images/setup-github-credentials-macos/Screen_Shot_2021-11-19_at_19.44.03.png)

Choose HTTPS:

![Terminal showing protocol selection with HTTPS option highlighted](https://flaviocopes.com/images/setup-github-credentials-macos/Screen_Shot_2021-11-19_at_19.44.07.png)

Choose Y:

![Terminal asking to authenticate Git with GitHub credentials, Y/n prompt shown](https://flaviocopes.com/images/setup-github-credentials-macos/Screen_Shot_2021-11-19_at_19.44.16.png)

And proceed to login with the browser:

![Terminal showing authentication method selection with Login with a web browser option highlighted](https://flaviocopes.com/images/setup-github-credentials-macos/Screen_Shot_2021-11-19_at_19.44.19.png)

Click **Authorize GitHub**:

![GitHub authorization page showing permissions for GitHub CLI with Authorize github button](https://flaviocopes.com/images/setup-github-credentials-macos/Screen_Shot_2021-11-19_at_19.44.36-redacted_dot_app.png)

And you're set:

![GitHub success page displaying Congratulations, you're all set! with green checkmark](https://flaviocopes.com/images/setup-github-credentials-macos/Screen_Shot_2021-11-19_at_19.44.42.png)

Go back to your terminal or VS Code, and things will work as expected.

![Terminal showing successful git push command with Everything up-to-date message](https://flaviocopes.com/images/setup-github-credentials-macos/Screen_Shot_2021-11-19_at_19.49.25.png)
