切换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)"
相关推荐
最贪吃的虎4 小时前
GitHub推送又超时了?试试SSH
运维·ssh·github
四千岁9 小时前
Obsidian + jsDelivr + PicGo = 免费无限图床:一键上传,全平台粘贴即发
前端·程序员·github
wusfe9 小时前
适配 Anthropic 兼容 AI 提供商的环境配置快速切换工具
github
m0_6948455710 小时前
marimo搭建教程:替代Jupyter的交互式开发工具
服务器·ide·python·docker·jupyter·github
梦梦代码精10 小时前
智能体编排 + MCP + 知识库,开源可商用!
人工智能·神经网络·gitee·开源·github·代码规范
前进的李工10 小时前
SSH隧道实现Dify与Ollama跨服务器通信
开发语言·大模型·github·腾讯云·autodl·dify
汪海游龙10 小时前
04.03 AI 精选:Google 发布 Gemma 4 开源模型
github
起个名字总是说已存在10 小时前
github开源AI技能:UI UX Pro Max智能设计系统生成器
人工智能·ui·开源·github
一叶飘零_sweeeet11 小时前
IDEA 集成 GitHub Copilot 指南:解锁 10 倍编码效率的全链路实战
github·intellij-idea·copilot