切换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)"
相关推荐
小弥儿9 小时前
GitHub今日热榜 | 2026-08-26:AI 大脑与知识管理扎堆
人工智能·学习·开源·github
阿里嘎多学长9 小时前
2026-08-24 GitHub 热点项目精选
开发语言·程序员·github·代码托管
其实防守也摸鱼9 小时前
信创是什么:一文读懂信息技术应用创新
人工智能·阿里云·云计算·github·copilot
秃秃秃秃哇10 小时前
fatal: the remote end hung up unexpectedl
github
峰向AI11 小时前
Label Studio:数据标注领域的"瑞士军刀",文本、音频、视频、图片、时序全部拿捏
github
逛逛GitHub12 小时前
把这个国产神器接入你的 Codex 或 Claude Code,图片秒变 3D 模型。
github
chongzhe13 小时前
AgentConnect:多 Agent 协作的开源版 Claude Tag
人工智能·github·源码
蚂蚁集团数据体验技术13 小时前
推荐免费工具,AntV 开源社区出品数据可视化产品 Sive
github·agent·数据可视化
用户693717500138414 小时前
前阵子刷屏的 Ox-Alpha 真身揭晓!GLM-5.3-Flash 上线,这价格真的杀疯了
前端·后端·github
浪潮行舟15 小时前
使用 Notion 和 GitHub 构建知识库系列一
github·notion