Tutorial Guide

How to Change Your GitHub Account on macOS

A complete step-by-step guide to switch GitHub accounts on your Mac

11. Remove Current GitHub Credentials

First, check which credential helper you're currently using:

git config --global credential.helper

Remove stored credentials from macOS Keychain (press Enter twice after the last line):

git credential-osxkeychain erase host=github.com protocol=https

💡 Manual Method: Open Keychain Access app (Cmd + Space, search "Keychain Access"), search for "github.com", and delete all GitHub-related entries.

22. Update Git Configuration

Check your current Git username and email:

git config --global user.name && git config --global user.email

Update to your new GitHub username:

git config --global user.name "Your New Name"

Update to your new GitHub email:

git config --global user.email "newemail@example.com"

Verify your changes were applied correctly:

git config --global --list

33. Logout from Current GitHub Account

Logout from your current GitHub account:

gh auth logout

44. Login with New GitHub Account

Login to GitHub with your new account:

gh auth login

📋 GitHub CLI Login Steps:

  1. Select GitHub.com as the host
  2. Choose HTTPS or SSH as your protocol
  3. Select Login with a web browser
  4. Authorize GitHub CLI in your browser
  5. Paste the one-time code when prompted

Verify you're logged in with the new account:

gh auth status

55. Update Repository Remote URLs

Navigate to your repository and check current remote URL:

cd /path/to/your/repo && git remote -v

Update remote URL to use HTTPS with new account:

git remote set-url origin https://github.com/new-username/repo-name.git

66. Test Git Operations

Test pulling from your repository:

git pull

Test pushing to your repository:

git push