-
-
Save yermulnik/017837c01879ed3c7489cc7cf749ae47 to your computer and use it in GitHub Desktop.
git_protocol: ssh | |
aliases: | |
personal: '!cp ~/.config/gh/hosts.yml.personal ~/.config/gh/hosts.yml && gh auth status' | |
work: '!cp ~/.config/gh/hosts.yml.work ~/.config/gh/hosts.yml && gh auth status' |
where do I put config.yml
?
@neeraj-htp Into ~/.config/gh/
thank you for the workaround...2 years on that issue and no update
God, thank you
Thank you
In Windows, config.yml
exist in C:\Users\your-username\AppData\Roaming\GitHub CLI
Thank you!
#config.yml
tyvm!
Thank you! Save a lot of time to re-authenticate
doing the lord work, thank you sir
This is really dang helpful.
Thanks a ton!
thank you very much!
f*cking love you
This is the best thing since sliced cheese. I do hope this will be solved by upstream. Thank you!
So good!
Thanks!
This is true the love of my life
thank you T_T
Thank you very much. It works great. But I had to add gh auth setup-git
to the aliases to make git recognize switched profiles. So, my aliases inside ~/.config/gh/config.yml
looks like as below currently:
aliases:
co: pr checkout
personal: '!cp ~/.config/gh/hosts.personal.yml ~/.config/gh/hosts.yml && gh auth setup-git && gh auth status'
work: '!cp ~/.config/gh/hosts.work.yml ~/.config/gh/hosts.yml && gh auth setup-git && gh auth status'
This method works like a charm with direnv
.
Suppose you have
~/work
~/personal
Put .envrc
in each dir and write the same thing.
ex.) ~/work/.envrc
/bin/cp ~/.config/gh/work.yml ~/.config/gh/hosts.yml && gh auth status
When you cd ~/work
, the command above is automatically run by direnv
.
https://github.com/cli/cli/releases/tag/v2.40.0
With the
v2.40.0
release, multi-account support is introduced togh
for GitHub.com and GitHub Enterprise and it is only the beginning!
Example
hosts.yml.personal
content:Example
~/.config/gh/hosts.yml.work
content:Add GH CLI aliases programmatically (or manually copy
config.yaml
to~/.config/gh/
):Example usage:
Use
gh work
to switch to your work profile.Windows users: replace
~/.config/gh
withC:\Users\YOUR_USERNAME\AppData\Roaming\GitHub CLI
(config.yaml
goes to the same location)ℹ️ UPD (20221012): gabe565/gh-profile provides alike functionality by means of GH CLI extension