切换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)"
相关推荐
Freak嵌入式20 分钟前
MicroPython LVGL基础知识和概念:显示与多屏管理
开发语言·python·github·php·gui·lvgl·micropython
zandy10111 小时前
【全新 3.0版本】openclaw github installation guide
github·openclaw·installation
Freak嵌入式1 小时前
MicroPython LVGL基础知识和概念:时序与动态效果
开发语言·python·github·php·gui·lvgl·micropython
北冥有羽Victoria2 小时前
OpenCLI 操作网页 从0到1完整实操指南
vscode·爬虫·python·github·api·ai编程·opencli
Thomas.Sir3 小时前
GitHub Copilot从入门到精通【从基础补全到智能代理,解锁AI编程全技能】
github·copilot·ai编程
Hhaizhr3 小时前
Hermes Agent频频超时?一招教你解决API网络连通问题
github
Renlijuande4 小时前
VSCode + GitHub Copilot + C语言环境(MinGW)配置攻略(2026版)
vscode·github·copilot
AI成长日志4 小时前
【GitHub开源项目专栏】TGI源码剖析:HuggingFace推理服务核心实现
开源·github
GISer_Jing4 小时前
AI Weekly | 2026年4月第二周 · GitHub热门项目与AI发展趋势深度解析
人工智能·github
代码搬运媛4 小时前
Open Core 模式:开源版与企业版的双仓库管理实践
github