切换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)"
相关推荐
LinXunFeng10 小时前
Obsidian - 使用 Share Note 分享笔记并自部署
前端·笔记·github
DayDaydream15 小时前
7 天涨了 8000+ Star,Agent Reach 想给 AI 装上互联网眼睛
github
天衍四九2 天前
Git从0到实战(四):冲突解决与版本回退 —— 别怕,出错了也能救
github
大刚测试开发实战2 天前
如何内网穿透访问本地私有化部署的TestHub
前端·后端·github
uhakadotcom3 天前
在python 的 工程化架构中 ,什么是 薄包装器层?
后端·面试·github
Avan_菜菜3 天前
AI 能写代码了,为什么我反而开始要求它先写文档?
前端·github·ai编程
逛逛GitHub4 天前
这个爆红的 GitHub 项目让 token 直接省 60–95%。
github
iccb10134 天前
5年,一个程序员是如何把私有化在线客服系统做到第一名的
前端·后端·github
蝎子莱莱爱打怪4 天前
AI Agent 相关知识扫盲:16 个概念+11张图+38个开源项目推荐
人工智能·github·agent
用户317723070364 天前
Pydub:用 Python 处理音频,不写废话
github