iTranslated by AI
The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
📘
Using a work GitHub account only for company repositories
TL;DR
I want to separate my GitHub accounts for personal and work use, but
switching id_rsa files is a hassle.
Conclusion: Use GitHub CLI
In Git's credential configuration, you can set authentication methods for specific domains.
While various authentication methods are available, GitHub CLI is the easiest to set up.
Steps
- Install gh
brew install gh
- Log in to GitHub with your work account in your default browser.
- Run the following command in your terminal to authenticate:
gh auth login
- Add the following to
$HOME/.gitconfig:- If the username for your company's repository is
kaishaand your personal work account username istanaka, usekaisha.
- If the username for your company's repository is
[credential "https://github.com/company_repo_username"]
helper = !gh auth git-credential
- Clone your company's private repository using
https. Confirm that user authentication is not required.
It's a good idea to use two different browsers, like Chrome and Firefox, to log in with your personal and work accounts separately.
Bonus
Though I haven't investigated it thoroughly, gitprof also seems easy.
Discussion