切换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)"
相关推荐
逛逛GitHub1 小时前
GitHub 上已开源,有人把《哈利·波特》中的笔记做出来了。
github
m0_738120722 小时前
PHP代码审计基础——面向对象(四)
android·开发语言·网络·安全·github·php
阿里嘎多学长2 小时前
2026-07-09 GitHub 热点项目精选
开发语言·程序员·github·代码托管
小帅不太帅4 小时前
我随手发了几张截图,白拿了一个月 AI 顶配会员
前端·github
程序员柒叔5 小时前
OpenCode 一周动态-2026-W28
人工智能·github·agent·opencode·hermes
Agent治理法学5 小时前
我开源了一套 AI Agent 框架:有性格、有规则、还会自己造工具
node.js·github
AI袋鼠帝6 小时前
开源WorkBuddy蓝皮书!从0到100最系统Agent实战指南~【建议收藏】
github·aigc
智脑API平台6 小时前
Codex Cloud 任务怎么用?GitHub 仓库、PR 审查和远程开发流程
github·codex·pr 审查
STDD6 小时前
n8n 实战工作流模板:GitHub→飞书通知、定时爬虫→数据库、Webhook→多渠道推送
爬虫·github·飞书
程序员老油条7 小时前
用 n8n 自建自动化:GitHub Push 后自动部署到服务器
服务器·自动化·github