切换github帐号

bash 复制代码
#!/bin/bash

# Get the current GitHub user
current_user=$(git config --global user.name)

if [ "$current_user" == "user1" ]; then
    # Switch to user2
    mv id_rsa id_rsa_user1
    mv id_rsa.pub id_rsa_user1.pub
    mv id_rsa_user2 id_rsa
    mv id_rsa_user2.pub id_rsa.pub

    # Configure Git for user2
    git config --global user.name "user2"
    git config --global user.email "user2@gmail.com"
    echo "Switched to user2"
else
    # Switch to user1
    mv id_rsa id_rsa_user2
    mv id_rsa.pub id_rsa_user2.pub
    mv id_rsa_user1 id_rsa  
    mv id_rsa_user1.pub id_rsa.pub

    # Configure Git for user1
    git config --global user.name "user1"
    git config --global user.email "user1@gmail.com"
    echo "Switched to user1"
fi

# Display the current user name and email
echo "Current GitHub user: $(git config --global user.name)"
echo "Current GitHub email: $(git config --global user.email)"
相关推荐
GoGeekBaird6 小时前
从 Prompt Engineering 到 Loop Engineering,我觉得 AI 开发这事儿终于开始变味了
后端·github
aosky8 小时前
一台电脑配置多个 SSH Key 对应不同的 GitHub 账号
运维·ssh·github
YuePeng13 小时前
凌晨 3 点告警群炸了,我用浏览器干了原本 XShell 才能干的事
后端·github
QN1幻化引擎14 小时前
自注意力机制 20 年了,我们终于让它学会"压缩记忆"
github
程序员柒叔15 小时前
Hermes Agent 一周动态-2026-W24
人工智能·github·agent·openclaw·hermes
专注VB编程开发20年17 小时前
通义比GITHUB Copilot差了10倍
github·copilot
驯龙高手_追风18 小时前
Gitlab本地服务器搭建及配置-详细教程
git·github
逛逛GitHub18 小时前
在你微信里用爽 Claude Code,我的开源 Skill 又更新了。
github
qq_白羊座18 小时前
Linux 压缩 / 解压(tar)命令 + 参数详解
linux·运维·github
LeoZY_19 小时前
CH347应用 USB转JTAG功能之:probe-rs搭配CH347下载MCU命令全指南
单片机·嵌入式硬件·mcu·开源·github