Skip to content
FLAVIO COPES
flaviocopes.com
2026

How to set GitHub credentials for macOS

By Flavio Copes

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.

~~~

Set up 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 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

Choose HTTPS:

Terminal showing protocol selection with HTTPS option highlighted

Choose Y:

Terminal asking to authenticate Git with GitHub credentials, Y/n prompt shown

And proceed to login with the browser:

Terminal showing authentication method selection with Login with a web browser option highlighted

Click Authorize GitHub:

GitHub authorization page showing permissions for GitHub CLI with Authorize github button

And you’re set:

GitHub success page displaying Congratulations, you're all set! with green checkmark

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

Tagged: Git · All topics
~~~

Related posts about git: