🤓
Thomas lab
Git&Github
Git&Github
  • Fetching & Pulling
  • Git alias
  • Git & Github : What is in .git ?
  • Git Rebase
  • Git reflog
  • Git Stash
  • Git tags
  • Git Workflow(Collaboration)
  • Quick High-Level
  • Git diff
  • Git installer
  • Reset & Revert commit
  • Github Collaborators
  • Github Basics
  • Introducing Git
  • Merging Branch
  • How to use multiple account
Powered by GitBook
On this page
  • If you want to use multiple account git.You can setup with docs as belows
  • Step 1 : ~/.ssh
  • Step 2: Add the SSH keys to your ssh-agent
  • Step 3: Copy public key and add your git account
  • Step 3 : Create Config file
  • Step 4 : How to clone repo project with ssh

How to use multiple account

If you want to use multiple account git.You can setup with docs as belows

Step 1 : ~/.ssh

ssh (Secure shell) is one of the protocols allow user login in server from remote

inside folder ssh, we storage the keys(public/private) key to communicate between client side/server side

Step 1.1 How to generate public/private key

cd ~/.ssh

ssh-keygen -t rsa -C "personal@email" -f"github-personal"

ssh-keygen -t rsa -C "work@email" -f"github-work"

options : -t : option -t used to define type of private key -f : option -f used to define direction of file for private key The -C flag allows for comments that get added as metadata at the end of the public key

Step 2: Add the SSH keys to your ssh-agent

Step 2.1 : What is ssh-agent ?

ssh-agent is a program run in background on Unix-like system and used to management ssh key

step 2.2 : Add the key

ssh-add -k ~/.ssh/github-personal

ssh-add -k ~/.ssh/github-work

This command line will storage private key in ssh-agent

Step 3: Copy public key and add your git account

cat ~/.ssh/github-personal

cat ~/.ssh/github-work

This command line will print the public in terminal

Step 3 : Create Config file

touch ~/.ssh/config

this command will create file config management list of ssh key

# Account for personal
Host github.com-personal
    HostName github.com
    User git
    IdentityFile ~/.ssh/github-personal

# Account for work
Host github.com-work
    HostName github.com
    User git
    IdentityFile ~/.ssh/github-work

warning:

  • setting global/personal git user/email account

Step 4 : How to clone repo project with ssh

git clone [email protected]{work/personal}:{the-repo-owner-user-name}/{the-repo-name}.git

user will edit link git, add more type

--------------END------------------------------

PreviousMerging Branch

Last updated 8 months ago

Hope your enjoy Author : Do Mizh Hieu

🌟