切换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)"
相关推荐
fthux3 小时前
装闭 RenoPit 源码解析(06):SSE如何实时推送AI装修分析进度
人工智能·ai·开源·github·open source·renopit
是烨笙啊5 小时前
拯救 GitHub stars 体验:从 Agent Skill 到浏览器插件
github
小弥儿5 小时前
GitHub今日热榜 | 2026-08-11:图原生基础设施首日登顶
学习·开源·github
码流怪侠7 小时前
用 WiFi 信号数人头:howmanypeoplearearound 项目深度解析
后端·开源·github
大强同学9 小时前
零成本部署0penList,三步搞定,我一分钱没花!
github
IT摆渡者13 小时前
VM EXSI7.0存储硬盘故障处理
大数据·linux·github
Narrastory13 小时前
我用 Claude Code 写代码不到 2 小时,却花了 3 天做完这个软件—Vibe Coding 的正确姿势,是设计不是生成
前端·人工智能·github
AI Dog14 小时前
GitHub 项目整体替换与大文件处理指南
github
March.s14 小时前
Nginx 服务器反向代理实战指南
服务器·nginx·github
逛逛GitHub14 小时前
在 Codex 中用这 4 个 SKill,让你拍的照片变高级。
github