切换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)"
相关推荐
zhang_adrian15 小时前
【使用Github Copilot自动按规范文档生成全部代码】
人工智能·github·copilot
代钦塔拉17 小时前
Git & GitHub 从入门到精通:全流程实战教程
git·github
阿里嘎多学长17 小时前
2026-05-30 GitHub 热点项目精选
开发语言·程序员·github·代码托管
lauo1 天前
从FunloomAI到ibbot:当你的手机不再是“手机”,而是你的AI副脑和生产节点
人工智能·智能手机·架构·开源·github
Hommy881 天前
【剪映小助手】贴纸处理接口
网络·开源·github·aigc·剪映小助手·视频剪辑自动化
AIMath~1 天前
向github中上传文件过大超过50M怎么办
网络·git·github
麷飞花1 天前
Github开源协议
github·开源协议
用户887665426632 天前
Git 和 GitHub 入门:从版本控制到团队协作,一篇文章讲清楚
面试·github
pipo2 天前
从“开机全靠猜”到任意位置重定位:我做了一个 ROS 2 3D LiDAR 导航系统
github
Cosolar2 天前
QwenPaw 源码学习指南
人工智能·架构·github