切换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)"
相关推荐
Hommy8812 小时前
【剪映小助手】视频处理接口
开源·github·音视频·视频剪辑自动化·剪映api
铁皮哥13 小时前
【agent 开发】Claude Code 的 Skill 是怎么被加载的?从 name/description 到 SKILL.md 再到资源文件
java·服务器·数据库·python·gitee·github·软件工程
老虎海子14 小时前
从零手搓一个 AI 编程助手:Mini Claude Code 完全指南
人工智能·git·vscode·python·github
lxllzwj520131416 小时前
Mac如何像shell一样丝滑的使用item2连接服务器.
服务器·macos·github
开发者每周简报17 小时前
十个奇异 github 项目
github
Arden Zhao17 小时前
Gihtub HTTP添加为HTTPS证书
https·github
HelloGitHub17 小时前
《HelloGitHub》第 122 期
开源·github
上海云盾-小余18 小时前
服务器入侵应急处置:入侵排查与溯源恢复全流程
运维·服务器·github
lpfasd12318 小时前
2026年第21周GitHub趋势周报
github
纪伊路上盛名在18 小时前
Github 命令行搜索工具
人工智能·数据分析·github