java,

Git Management

Cui Cui Follow Dec 24, 2021 · 1 min read
Git Management
Share this

Multi github accounts

Generate your personal ssh key credentials

KEY_NAME=colorfulmetaman-github-`date +%Y-%m-%d`

ssh-keygen -t rsa -b 2048 -C $KEY_NAME -f ~/.ssh/github/$KEY_NAME

ssh-add ~/.ssh/github/$KEY_NAME

eval "$(ssh-agent -s)"

Update .ssh config, to allow personal account for specific host

vi ~/.ssh/config

# Personal account, - the default config
Host github.com
   HostName github.com
   User git
   IdentityFile ~/.ssh/github/$KEY_NAME

Switch identity, for git commands

//removes all ssh entries from the ssh-agent
ssh-add -D

// Adds the relevant ssh key
$ ssh-add ~/.ssh/github/$KEY_NAME

Confirm local git config is right identity info

// list
git config --global -l

// where configured
cat ~/.gitconfig

// update, from the global config file 
vi ~/.gitconfig
[user]
	name = zcui
	email = zcui@akamai.com
[includeIf "gitdir/i:~/Workspace/GitHub/"]
    path = ~/.github.gitconfig

// create specific config for the conditional repos
vi ~/.github.gitconfig
[user]
	name = ColorfulMetaMan
	email = superman.metaverse@gmail.com
Join Newsletter
Get the latest news right in your inbox. We never spam!
Cui
Written by Cui Follow
Hi, I am Z, the coder for cuizhanming.com!