#!/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)"
文章来源地址https://www.toymoban.com/news/detail-661825.html
文章来源:https://www.toymoban.com/news/detail-661825.html
到了这里,关于切换github帐号的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!