This script is designed to help you switch between different Git accounts on your Macbook. It allows you to set your Git username and email, as well as the SSH key associated with your Git account.
- Download the
git-account-switcher.sh
script to your Macbook. - Open a terminal and navigate to the directory where you saved the script.
- Make the script executable by running the following command:
chmod +x git-swith.sh
To use the script, follow these steps:
- Open a terminal and navigate to the directory where you saved the
git-account-switcher.sh
script. - Run the script by typing
./git-account-switcher.sh
and pressingEnter
. - Follow the prompts to enter your Git username, email, and select your SSH public key file.
- If your SSH key has a passphrase, enter it when prompted.
- The script will set your Git account information and add your SSH key to the SSH agent.
You can also create an alias to run the script with a shorthand command. To do this, add the following line to your .bash_profile
file:
alias switch-git-account='/path/to/git-switch.sh'
Replace /path/to/git-account-switcher.sh
with the actual path to the script on your Macbook. For example, if you saved the script in your home directory, the path would be ~/git-switch.sh
.
Once you've added the alias, you can run the script by typing switch-git-account
in the terminal.
If you're having trouble using the script, make sure you have the following:
- A valid Git account with a username and email address.
- An SSH key associated with your Git account. If you don't have an SSH key, you can generate one using the
ssh-keygen
command. - The
ssh-agent
process running in the background. You can start thessh-agent
by running the commandeval $(ssh-agent)
. - The
ssh-add
command installed on your Macbook. You can install it using Homebrew by running the commandbrew install openssh
.
This project is licensed under the MIT License. Feel free to use, modify, and distribute this script as you see fit.