Skip to content

Git Multiple user setup

Published: at 06:26 AM

Table of contents

Open Table of contents

How to add new user’s ssh key

1. Generate new ssh key

ssh-keygen -t rsa -C "user2@email.com"

名字加后缀,不要覆盖之前的key

2. Add pub key into github ssh

3. update file~/.ssh/config

Host xxwhatever
HostName ssh.github.com
User git
Port 443
IdentityFile /Users/sober/.ssh/yourkeyname
IdentitiesOnly yes

Change local repo’s current user

1st method

git config --local user.name "xxx"
git config --local user.email "xxx"

2nd method

Another method is to update file.git\config KOjbCltest

Add remote repo with non-global git user

git remote/clone add origin git@xxwhatever:repoUrl