A complete step-by-step guide to switch GitHub accounts on your Mac
First, check which credential helper you're currently using:
git config --global credential.helperRemove 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.
Check your current Git username and email:
git config --global user.name && git config --global user.emailUpdate 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 --listLogout from your current GitHub account:
gh auth logoutLogin to GitHub with your new account:
gh auth loginVerify you're logged in with the new account:
gh auth statusNavigate to your repository and check current remote URL:
cd /path/to/your/repo && git remote -vUpdate remote URL to use HTTPS with new account:
git remote set-url origin https://github.com/new-username/repo-name.gitTest pulling from your repository:
git pullTest pushing to your repository:
git push