切换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)"
相关推荐
RickeyBoy2 小时前
Git Worktree / Worktrunk:并行 AI 开发工作流实战
github·vibecoding
逛逛GitHub9 小时前
55 个 AI Agent 组成虚拟公司开源,2 天就 1 万星
github
Tapir13 小时前
被 Karpathy 下场推荐的 NanoClaw 是什么来头
前端·后端·github
ShingingSky13 小时前
用 Claude Skill 改造 AgentTeams:我实现了 AI 协作的质变
github
Moment15 小时前
MinIO已死,MinIO万岁
前端·后端·github
草梅友仁19 小时前
OpenClaw AI 助手实测与墨梅博客更新 | 2026 年第 10 周草梅周报
开源·github·ai编程
ExcellentWe1 天前
你的AI写的代码总是不理想?这个开源免费的工程流水线编排工具super-dev帮你解决
github
Moment2 天前
腾讯终于对个人开放了,5 分钟在 QQ 里养一只「真能干活」的 AI 😍😍😍
前端·后端·github
小兵张健2 天前
开源 playwright-pool 会话池来了
前端·javascript·github
goodspeed2 天前
Git Worktree:多分支并行开发的利器
git·github