切换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)"
相关推荐
用户7273744138848 小时前
JSON 转义字符到底该怎么读:几种常见场景
github
SL_staff8 小时前
考勤同步工资核算总出错?破解企业级精准自动化的三个刚性支点
mysql·github·全栈
webxin6669 小时前
汽水music自动看广告领取VIP
程序员·github
梦里寻码10 小时前
给 AI Agent 搭围栏:Monorepo 是被低估的 Agent 基础设施
前端·后端·github
穆梓兰煊11 小时前
Flutter端云协同推理架构解析
flutter·github
七牛云行业应用12 小时前
DeepSeek Harness 自定义 Skill 教程:从 SKILL.md 到可复用 Agent 工作流
算法·github
逛逛GitHub12 小时前
清华在 GitHub 上开源的 Agent 工作台,最近更新了 2.0 版本。
github
u13013014 小时前
GitHub 热榜项目:日榜(2026-10-14)
人工智能·github
誰能久伴不乏16 小时前
QT工业上位机一次「指令静默丢失」的排查
qt·docker·github
胡大伟16 小时前
麦当劳的开发者大赛:麦当劳 MCP 实测——一个藏在 inputSchema 里的参数
github