切换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)"
相关推荐
用户202252215065 小时前
我在 DSH 做了个 AI 交付验收台:没有证据,就不算通过
github
前端市界6 小时前
Pro React Admin: 统一工程底座,承载多种应用...
前端·github
穆梓兰煊10 小时前
Rust 重写 AI 基础设施的工程逻辑
github
邱杰47011 小时前
数智人事系统(三):Spring Boot 3.4 骨架与配置分层
github
空空dream12 小时前
Github | 初始化空白仓库到首次推送
github
高频因子挖掘机13 小时前
A股分钟K线数据占内存:先缩小请求范围,还是换 DataFrame 工具?
后端·github·api
miofly15 小时前
Karpathy:75%人口未接触LLM,约5000人可用的内部系统已让数千智能体协作数周
开源·github
zjh102416 小时前
和 AI 一起写了个 MCP 客户端,结果最难的不是协议
github