切换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)"
相关推荐
流量猎手4 小时前
宝塔中更新github
github
敢敢是只喵i8 小时前
n8n 接入业务系统:如何正确等待一项 Agent 任务?从稳定 request_id、job_id 到超时续查
github
wangruofeng8 小时前
新 Mac 到手先装什么:AI Builder 的 44 款工具,基础层照抄、场景层按需
github·aigc·ai编程
亖十不惑8 小时前
二、Codex Memories 源码解析:记忆的生成、整理与存储
github
面向Google编程8 小时前
GitHub 宕机近 8 小时!一次 sidecar 配置失误,如何放倒全球最大代码平台
github
峰向AI9 小时前
Modular 平台:一个人想改写 AI 开发的底层规则
github
IvanCodes12 小时前
GitHub 本周热门开源项目:Agent Infra与端侧 AI|8.17–8.23
开源·github
高频因子挖掘机12 小时前
量化交易系统的数据层和策略层如何解耦?从紧耦合泥潭到优雅分层架构
后端·github
量化小c12 小时前
从数据到策略:QuantDash + DuckDB 搭建 5 分钟 K 线本地量化数据仓库
后端·github
fthux12 小时前
装修怕增项、合同看不懂?我做了 RenoPit,帮普通业主提前发现装修坑
人工智能·ai·开源·github·open source·renopit