切换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)"
相关推荐
dadaobusi16 分钟前
.gitignore配置问题
github
CoderJia程序员甲19 分钟前
GitHub 热榜项目 - 日榜(2026-03-27)
人工智能·ai·大模型·github·ai教程
Carsene1 小时前
艺术化你的 Git 提交:类型与图标(全网最全)的实践准则
git·github
badhope2 小时前
10个GitHub高星开源项目推荐
大数据·人工智能·深度学习·数据挖掘·github
汪海游龙2 小时前
03.28 AI 精选:用树搜索自动完成科研发现的智能体系统
github
旺旺的碎冰冰~3 小时前
解决VScode使用GitHub Copilot生成的命令行无法显示问题
vscode·github·copilot
逛逛GitHub19 小时前
7 个最近 GitHub 上火火火的开源项目,推荐一哈。
github
__雨夜星辰__19 小时前
什么是 Git 与 Git※hub(※Git※hub加※速访※问教程)
git·github
子夜江寒19 小时前
GitHub入门协作
github
逛逛GitHub20 小时前
一个运维人写了 12 年的开源项目,Star 刚刚破了 3 万。
github