本地切换Github账号
·
命令行里主要切两处:gh 登录账号,以及 Git 推送用的凭据。
查看当前账号:
gh auth status
git credential-manager github list
切换到已登录过的 gh 账号:
gh auth switch --hostname github.com --user 【账号名】
如果还没登录该账号:
gh auth login --hostname github.com --git-protocol https --web
如果只想让当前项目用某个账号推送,可以在项目目录执行:
git config credential.https://github.com.helper manager
git config credential.https://github.com.username 【账号名】
如果要重新添加 Git Credential Manager 里的账号:
git credential-manager github login --username 【账号名】 --browser --force
如果要删除旧账号,例如 myaccount:
git credential-manager github logout 【账号名】
以后推送失败时,先查这几个值最直接:
gh auth status
git config --get credential.https://github.com.username
git config --get http.proxy
git remote -v更多推荐




所有评论(0)