切换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)"
相关推荐
ByteCraze32 分钟前
从零到一:构建一个实时语音翻译应用(Vue3 + Web Speech API)
前端·开源·github
修炼者2 小时前
如何让git识别不到你的文件
git·github
小猪佩奇TONY2 小时前
常用软件工具的使用(2) ---- git 命令进阶 和 github
git·github
这是个栗子3 小时前
git报错:Reinitialized existing Git repository in ...
前端·git·github
CoderJia程序员甲3 小时前
GitHub 热榜项目 - 日榜(2025-12-13)
ai·开源·大模型·github·ai教程
Nautiluss13 小时前
一起玩XVF3800麦克风阵列(八)
大数据·人工智能·嵌入式硬件·github·音频·语音识别
uhakadotcom17 小时前
Python Protobuf 全面教程:常用 API 串联与实战指南
前端·面试·github
周杰伦_Jay19 小时前
【GOFrame】模块化框架与生产级实践
开发语言·gitlab·github
托马斯-酷涛1 天前
加速GitHub加载速度-最终篇
github·proxy·代理
yuguo.im1 天前
5 分钟快速入门 Github Actions
ci/cd·github·actions