切换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)"
相关推荐
长不大的杨瑞杰3 小时前
GitHub Copilot Browser Use 实战:让 AI 在浏览器里调试与自动化测试
人工智能·github·copilot·playwright·github copilot·browser use
大侠Luffy4 小时前
用 EmbeddingGemma 2 做一个本地照片与短视频搜索工具
开源·github·ai编程
咖啡色格调4 小时前
项目已托管在 Gitee,如何同时推送到 GitHub
gitee·github
人人都是软件工程师4 小时前
前端接了 Agent,为什么还是满屏自定义代码?读懂 AG-UI 的 31 个事件
人工智能·github
怕浪猫5 小时前
GLM-5.4 深度拆解:750B 参数如何「循环」出 2-3T 级智能?
算法·面试·github
李永奉6 小时前
Git和GitHub-Git 管理的版本数据到底保存在哪个文件夹里?
git·github
wflynn1 天前
GitHub 今日推荐|univer:可嵌入 Web 应用的开源 Office 引擎
typescript·开源·github·doc·collaboration·board
dong_junshuai1 天前
每天一个开源项目#163 Ghost Downloader:分块下载为何不用合并
github
网易云信1 天前
AI 写 IM 集成总用错 API?用云信 AI Skills 把文档接进开发流程
github
猛码象限1 天前
【GitHub 周报】换血八成,注意力从造 Agent 转向管 Agent
github·业界资讯