切换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)"
相关推荐
Albert_Lsk5 小时前
【2025/07/11】GitHub 今日热门项目
人工智能·开源·github·开源协议
心.c6 小时前
后台管理系统-权限管理
javascript·react.js·github
一点一木7 小时前
🚀 2025 年 06 月 GitHub 十大热门项目排行榜 🔥
前端·人工智能·github
寻月隐君8 小时前
Rust 错误处理终极指南:从 panic! 到 Result 的优雅之道
后端·rust·github
b1ng8 小时前
新人程序员 Git 一站式指南
git·github
叶怀生9 小时前
Github创建仓库并通过VS Code推送项目
github
ai小鬼头20 小时前
AIStarter新版重磅来袭!永久订阅限时福利抢先看
人工智能·开源·github
如何原谅奋力过但无声20 小时前
上传GitHub步骤(自用版)
github
jingshaoqi_ccc1 天前
GitKraken最后一个免费版本和下载地址
git·github·gitkraken·版本管理工具
乌云暮年1 天前
Git简单命令
git·gitee·github·batch命令