切换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)"
相关推荐
保卫大狮兄7 小时前
2小时,我搭了一套仓库出入库管理系统:收货、领料、退料、库存全打通!
wms·github·仓库·入库
沙蒿同学7 小时前
不引 Ghostscript:我用纯 Go 给 PDF 做了一场「压缩手术」
前端·后端·github
wflynn12 小时前
GitHub 日榜趋势速报 | 2026-10-23
开源·github
miofly13 小时前
Anthropic开源MHS标准,让AI智能体直接操作实验室硬件
开源·github
m4Rk_14 小时前
【论文阅读】Agent记忆机制(109):MemComposer——用强化学习学会选哪些记忆、选多少以及怎样排序
论文阅读·人工智能·学习·开源·github
Orange Wu15 小时前
GitHub SSH 443 端口配置解决连接失败
github
左手吻左脸。15 小时前
新环境配置git
github
miofly15 小时前
GitHub 今日推荐|dquickts:能暂停、能存档的 QuickJS
开源·github
import_random15 小时前
[git]只有git,没有github, 如何工作
git·github
import_random15 小时前
[git]先创建远程仓库or先创建本地项目
git·github