切换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 小时前
2026-10-20 GitHub 热点项目精选
开发语言·程序员·github·代码托管
高频因子挖掘机7 小时前
本地已有一年历史数据,第二天更新别只拉“昨天一天”:量化 K 线增量同步实践
后端·github·api
高频因子挖掘机7 小时前
只补缺失日期,不重拉全部历史:增量更新 K 线应该怎么设计?
后端·github·api
逛逛GitHub13 小时前
我用 Codex 破解了家里这个设备,还能语音遥控。。。
github
风之九子15 小时前
在上游一天两版的项目上做二次开发:9 天 65 次提交的 fork 手记 (dsh-our-free-model)
人工智能·ai·github
邱杰47016 小时前
数智人事系统(十七):加班核算与薪资构成
后端·github
小弥儿16 小时前
GitHub今日热榜 | 2026-10-20:智能体基建七席连庄,生成类项目回流
学习·开源·github
江厌0116 小时前
两张卡部署两个模型:物理分卡、MIG、张量并行的选择与可复现配置
github·模型部署·vllm
问天_观心16 小时前
模型微调学习(二)
开发语言·人工智能·学习·语言模型·github
回眸&啤酒鸭17 小时前
【回眸】GitHub Copilot 智能编程辅助效果实测
github·copilot