切换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)"
相关推荐
m4Rk_7 小时前
【论文阅读】Agent 记忆机制(94):MemGen——在推理过程中动态生成并织入潜在记忆
论文阅读·人工智能·学习·开源·github
wflynn8 小时前
GitHub 今日推荐|ts-rust:把微软 TypeScript-Go 编译器逐行移植成 Rust 实现
rust·typescript·开源·github·compiler·tsc
明月_清风8 小时前
面对陌生的 GitHub 项目无从下手?这 4 个网站帮你快速读懂源码
前端·后端·github
SL_staff9 小时前
Excel如何自动升级为可搜索的知识节点:JVS文档平台的语义解析实践
开源·github·全栈
miofly9 小时前
GitHub 今日推荐|wordcraft:用 Rust 重写 Word 内核并开放给 AI 调用
rust·开源·github
miofly9 小时前
Fold:Effect原生多提供商Agent核心框架解读
开源·github
诚小纯9 小时前
跑了 21 次只有 1 次透明:聊聊一个生图 API 的"透明继承"机制
人工智能·github
用户2991422196809 小时前
GitHub 热榜项目:日榜(2026-10-09)
人工智能·开源·github
fundoit10 小时前
为什么需要 Access Token 和 ID Token 两个令牌
java·spring·架构·github·oauth2
逛逛GitHub10 小时前
3 个最近爆火的 Personal Agent ,在 GitHub 上有开源平替了。
github