切换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)"
相关推荐
一拳不是超人16 小时前
一个 AI 改出的 bug,另一个 AI 五天就打穿了 Snowflake:Copilot Autofix 事件给 coding agent 的警醒
架构·github
微学AI17 小时前
把 GitHub Issue 的“第一轮脏活”交给 AI:Issue AI Agent 接入蓝耘元生代实战
人工智能·github·issue
阳墨余19 小时前
Git 同时管理 Gitee 和 GitHub 的 SSH 配置实战
git·gitee·github
小弥儿1 天前
GitHub今日热榜 | 2026-08-16:大模型微调与编码工具扎堆
学习·开源·github
starp1 天前
skill 管理,后缀为public可以被git commit
github
31535669131 天前
DeepSeek Harness 发布后,我没急着跑 Demo,先把 `.agents/` 翻了一遍
前端·后端·github
u1301301 天前
GitHub 热榜项目:周榜(2026-08-16)
github
暮云星影1 天前
git版本发布
git·gitee·github·gitea
m4Rk_1 天前
【论文阅读】Agent 记忆机制(41):Agentic Plan Caching——将历史执行轨迹转化为可复用的计划记忆
论文阅读·人工智能·学习·开源·github