切换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)"
相关推荐
怕浪猫1 小时前
Prompt Engineering 面试怎么考?这 5 个范式你必须会
面试·程序员·github
可乐ea5 小时前
GitHub Security Lab 开源 Fuzzing Taskflow:让 LLM 智能体自己跑完 C/C++ 模糊测试
jvm·c++·github·模糊测试·mcp·代码agent·智能体自动化
TOOLS指南6 小时前
GitHub 和 ai.github 是什么?两者有什么区别
人工智能·github
贾斯汀frank7 小时前
Fleurdelix OS已预装办公套件ONLYOFFICE桌面编辑器
github
wflynn7 小时前
GitHub 日榜趋势速报 | 2026-09-30
开源·github
Cosolar13 小时前
云端部署阿里 Qwen-Image-2.1 保姆级教程
人工智能·后端·github
miofly14 小时前
GitHub 今日推荐|REDox:64 位 token 表示结构化数据,内存占用降 70% 支持多格式互转
开源·c#·github
奋进的LY14 小时前
spacy的安装和使用教程
人工智能·python·深度学习·github
guru14 小时前
手写一个 Tool-Calling Agent:为什么要先不用框架
github
miofly15 小时前
GitHub 日榜趋势速报 | 2026-10-03
开源·github