切换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)"
相关推荐
CoderJia程序员甲9 小时前
GitHub 热榜项目 - 日榜(2026-02-05)
ai·开源·大模型·github·ai教程
weixin_66810 小时前
GitHub 2026年AI项目热度分析报告-AI分析-分享
人工智能·github
MicrosoftReactor12 小时前
技术速递|GitHub Copilot CLI 斜杠命令速查表
github·copilot·cli
wu~97012 小时前
GitHub永不遗忘,使用git push -f来覆盖的提交依旧保留
git·github
m0_6948455712 小时前
music-website 是什么?前后端分离音乐网站部署实战
linux·运维·服务器·云计算·github
独自破碎E12 小时前
已经 Push 到远程的提交,如何修改 Commit 信息?
开发语言·github
jiang_changsheng15 小时前
工作流agent汇总分析 2
java·人工智能·git·python·机器学习·github·语音识别
馨谙15 小时前
Ansible 配置文件详解:让自动化管理更轻松
运维·github·ansible
Gofarlic_OMS16 小时前
Altium许可证状态自动化监控方案
大数据·运维·服务器·人工智能·自动化·github
岱宗夫up16 小时前
GitHub Desktop如何设置中文?这不是个简单问题
git·github