Skip to content

Instantly share code, notes, and snippets.

@perfmind
Created July 8, 2020 05:26
Show Gist options
  • Select an option

  • Save perfmind/fbf2edbc09798d94a079a530105dd854 to your computer and use it in GitHub Desktop.

Select an option

Save perfmind/fbf2edbc09798d94a079a530105dd854 to your computer and use it in GitHub Desktop.
Change SSH Key, it's convenient when you have multiple git repository account.
work sulton@work.com
contribution sulton@contribution.com
personal shcode@personal.com
# Create folder ~/.ssh_profile and put yout ssh key based on profile
# If you have 3 different account you must create 3 folder, for example: personal, work, contribution
# Create file .ssh_email and fill with your associated email for your accounts
#
csk() {
if `ls -1 ~/.ssh_profile | grep -q $1`; then
rm ~/.ssh
ln -s ~/.ssh_profile/$1 ~/.ssh
ssh_email=`cat ~/.ssh_profile/.ssh_email | grep "$1\t" | sed "s/$1 //"`
git config --global user.email $ssh_email
else
echo "ssh profile $1 not found."
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment