切换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)"
相关推荐
阿里嘎多学长1 分钟前
2026-09-20 GitHub 热点项目精选
开发语言·程序员·github·代码托管
峰向AI44 分钟前
skill-up: [阿里开源] 让 AI Agent Skills 自己进化的评估工具
github
子林super4 小时前
顺序表用Python3定义与增删改查
github
子林super4 小时前
Python非空判断与类型检查写法
github
子林super4 小时前
Python list与array关键区别及使用场景
github
子林super4 小时前
Python中None与null的区别
github
u1301307 小时前
GitHub 热榜项目:周榜(2026-09-20)
人工智能·github
u1301308 小时前
GitHub 热榜项目:日榜(2026-09-20)
人工智能·github
逛逛GitHub8 小时前
外网 3500 万人围观的 Jev 模型,有这 10 个神奇玩法。
github
m4Rk_9 小时前
【论文阅读】Agent 记忆机制(76):SEEM——从碎片检索到完整事件重建
论文阅读·人工智能·学习·开源·github