Guide

Multiple GitHub accounts on one Mac.

Personal projects, your job, a client or two: most developers juggle more than one GitHub account. Boughwright lets you connect all of them and pick the one that commits and pushes in each repository.

Why several GitHub accounts on one Mac go wrong

Git has one global identity and one stored credential per host. As soon as you have a second GitHub account, a few things start to break:

  • Commits carry the wrong email. Your personal address ends up in your employer's history, or your work address in your open-source contributions.
  • Pushes use the wrong login. macOS Keychain stores one github.com credential, so git pushes as whoever signed in last and gets “permission denied” on the other account's repositories.
  • The usual fixes are fiddly. SSH host aliases such as github-work mean rewriting every remote. includeIf blocks in ~/.gitconfig only fix the email, and only for folders you remembered to list.

How Boughwright keeps accounts apart

  1. Connect each account once

    Sign in on GitHub with a one-time code, or paste a personal access token. Tokens go into your macOS Keychain. GitHub Enterprise hosts work too.

  2. Boughwright matches repositories to accounts

    If a repository's remote belongs to your login or to one of your organisations, that account is selected for it automatically.

  3. Check or change it before you commit

    The account appears in the repository header and right above the Commit button. Pick another one from the menu and Boughwright remembers it for that repository.

  4. Commit and push as that account

    The commit gets that account's name and email, and the push uses its token or SSH key, for that one command only.

Click a card to switch accounts
github.com/isurutmv/dotfilespush as @isurutmv
git@github.com:acme/portalpush as @isuru-acme
git@github.com:lichen/lichenpush as @lichen-bot

Compared with the manual setups

ApproachRight commit emailRight push credentialsRemotes stay unchangedSetup per new repo
SSH host aliases in ~/.ssh/configNoYesNo, rewrite each remoteEdit the remote URL
includeIf in ~/.gitconfigYes, by folderNoYesKeep folders organised
gh auth switchNoYes, globallyYesSwitch before every push
BoughwrightYesYesYesNone, or pick once

What happens under the hood

Boughwright never edits your ~/.gitconfig or ~/.ssh/config. For each git command it adds settings that apply to that command only:

  • Commits get user.name and user.email from the chosen account.
  • Pushes, pulls and fetches get a credential helper scoped to https://github.com (or your Enterprise host) that answers with the account's token. Other hosts keep your normal credentials.
  • The token travels in an environment variable, so it never appears in a config file or the process list.
  • For git@github.com remotes, the account's own SSH key is used, or the push goes over HTTPS with its token.
ChangesHistoryBranchesStashesTagsRemotes
FetchPullPush 2
AP
acme-portal
⎇ feat/checkout
STAGED 2
ACheckoutSheet.swift Views/
MCart.swift Models/
CHANGES 2
MPaymentService.swift Services/
Ustripe-keys.example
Committing as Acme (work) · isuru@acme.dev
Add Apple Pay to checkout
Description
Commit 2 filesCommit & Push
MServices/PaymentService.swift+6 −2
@@ -41,7 +41,11 @@ func authorizeStage Hunk
4141 let amount = cart.total
42 return try await card.charge(amount)
42+ switch method {
43+ case .applePay(let token):
44+ return try await wallet.pay(token, amount)
45+ case .card(let card):
46+ return try await card.charge(amount)
47+ }
4348 }
@@ -88,4 +93,4 @@ enum PaymentErrorStage Hunk
88 case declined("Card declined")
93+ case declined("Payment declined")
Try the account menu in the header. The “Committing as” line follows it.

Questions about multiple accounts

Can I use two GitHub accounts on the same Mac?

Yes. Connect both accounts in Boughwright and choose one per repository. Commits use that account's name and email, and pushes use its token, without editing ~/.gitconfig or ~/.ssh/config.

How do I stop committing to work repositories with my personal email?

Assign your work account to the work repositories. Boughwright does this automatically when the remote belongs to your work organisation, and it shows the account right above the Commit button so you can see which identity you're about to use.

Do I still need SSH host aliases like github-work?

No. You can give each account its own SSH key, or let Boughwright send git@github.com remotes over HTTPS with that account's token. Your remotes can stay as plain git@github.com URLs.

Where are my tokens stored?

In the macOS Keychain. They're passed to git through environment variables for a single command, so they never appear in a config file or in the process list.

Boughwright app icon

Tidy up your git.

Download Boughwright free, point it at your code folder, and connect your accounts. It takes about a minute.