切换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)"
相关推荐
annekqiu3 小时前
VS code 部署agent
github·visual studio code
BerryS3N7 小时前
GitHub Actions自动化运维实战:从CI/CD到云端部署的完整指南
运维·自动化·github
胡萝卜术7 小时前
V040:RAG 检索增强生成的工程链路解构与生产级系统设计
面试·架构·github
鱼樱前端17 小时前
别再自己拼凑了!这款 Vue 3.5+ 严肃产品级组件库,把 AI 对话、工作流和复杂数据全包了!
javascript·vue.js·github
阿里嘎多学长18 小时前
2026-07-14 GitHub 热点项目精选
开发语言·程序员·github·代码托管
IpdataCloud19 小时前
跨区服玩家延迟高怎么办?用IP离线库自动分配到最近服务器
数据库·tcp/ip·github·php·ip
OpenTiny社区21 小时前
TinyEngine 2.11版本发布:AI 进一步融入画布,Vue 工程可一键转DSL
前端·vue.js·github
七牛开发者1 天前
RAG 工程里的上下文剪枝:如何减少 68% 的上下文
前端·css·github
Alex6630281 天前
我重写了 Hermes Agent,专门修掉了它的 4 个硬伤
github
考虑考虑1 天前
git中的tag
git·gitlab·github