切换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)"
相关推荐
dreams_dream2 小时前
项目想要推送多个平台仓库的方法
gitee·github
AI_Lab012 小时前
服务器管理工具要在服务器上装 Agent,安全吗?
服务器·安全·github
七牛云行业应用2 小时前
DeepSeek Harness 插件架构 vs MCP:Cordis 的「Everything is a Plugin」到底解决什么
ai·github·ai编程
u1301303 小时前
GitHub 热榜项目:日榜(2026-10-30)
人工智能·github
AlfredZhao3 小时前
新项目首次提交 GitHub 报错“未配置远端 origin”怎么办
github
miofly3 小时前
GitHub 日榜趋势速报 | 2026-10-31
开源·github
u13013015 小时前
GitHub 热榜项目:日榜(2026-10-29)
人工智能·github
穆梓兰煊16 小时前
Python 千万级向量检索内存优化手册
github
用户8371332007616 小时前
AI总是会忘记细节咋办?我用GitHub实现外部记忆管理
人工智能·github
逛逛GitHub17 小时前
这 6 个 GitHub 项目是刚开源,但是 Star 攀升很快的几个。
github