切换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)"
相关推荐
七分辣度6 分钟前
GitHub/Git 常用命令及使用场景
git·github
dong_junshuai20 分钟前
每天一个开源项目#160 LoopForge:把Agent交付拆成可退回的验收流程
github
Allen36682 小时前
给博客和秘书加上 HTTPS 之后的一点记录
github
laoyeye8313 小时前
手写 vLLM 分页 KV Cache(二):深入物理块分配、Block Table 与 Slot Mapping
github
Summer-Bright5 小时前
企业落地智能体,供应链签名还是空白:1862 个 MCP 服务器无认证裸奔
服务器·人工智能·github·mcp
一条Go5 小时前
Pod 终端与日志:为什么浏览器建连要先换一张 60 秒的票
后端·架构·github
一条Go5 小时前
开源新生代雷达 · 第 14 期
github
徐小夕8 小时前
万字拆解:零向量库、无模型微调,SAG2 凭什么刷新多跳问答 SOTA
前端·vue.js·github
黑土豆8 小时前
用 drawink 给业务页面加一层画板:从网页批注到无限板书
前端·javascript·github
dong_junshuai1 天前
每天一个开源项目#159 Plannotator:把Agent审阅做成异步消息
github