切换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)"
相关推荐
徐小夕2 小时前
JitArchives,一款基于JitWord协同AI文档打造的企业级电子档案系统
前端·vue.js·github
特创数字科技3 小时前
写了个 Windows 下载器:一键拉 GitHub / Gitee 源码,带 SHA256 校验
python·github
miofly5 小时前
GitHub 日榜趋势速报 | 2026-11-09
开源·github
miofly20 小时前
Nous Research微调Qwen3.8-27B,宣称可剥离中国官方立场内容
开源·github
用户2991422196801 天前
GitHub 热榜项目:周榜(2026-11-08)
人工智能·开源·github
用户2991422196801 天前
GitHub 热榜项目:日榜(2026-11-08)
人工智能·开源·github
miofly1 天前
GitHub 周榜趋势速报 | 2026-11-08
开源·github
miofly1 天前
GitHub 日榜趋势速报 | 2026-11-08
开源·github
miofly2 天前
百度开源ERNIE 5.5 Flash Base,总参数280B仅激活14B
开源·github
dong_junshuai2 天前
每天一个开源项目#154 Nushell:结构化管道怎样跨过文本边界
github