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-workmean rewriting every remote.includeIfblocks in~/.gitconfigonly fix the email, and only for folders you remembered to list.
How Boughwright keeps accounts apart
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.
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.
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.
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.
github.com/isurutmv/dotfiles→push as @isurutmvgit@github.com:acme/portal→push as @isuru-acmegit@github.com:lichen/lichen→push as @lichen-botCompared with the manual setups
| Approach | Right commit email | Right push credentials | Remotes stay unchanged | Setup per new repo |
|---|---|---|---|---|
SSH host aliases in ~/.ssh/config | No | Yes | No, rewrite each remote | Edit the remote URL |
includeIf in ~/.gitconfig | Yes, by folder | No | Yes | Keep folders organised |
gh auth switch | No | Yes, globally | Yes | Switch before every push |
| Boughwright | Yes | Yes | Yes | None, 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.nameanduser.emailfrom 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.comremotes, the account's own SSH key is used, or the push goes over HTTPS with its token.
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.
Keep reading
Tidy up your git.
Download Boughwright free, point it at your code folder, and connect your accounts. It takes about a minute.