Skip to content

Instantly share code, notes, and snippets.

@minhloc2011
Last active May 21, 2019 03:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save minhloc2011/777e2dfafc3398b827bc8a2633e7ccea to your computer and use it in GitHub Desktop.
Save minhloc2011/777e2dfafc3398b827bc8a2633e7ccea to your computer and use it in GitHub Desktop.

Ở đây ví dụ mình có 2 accounts: 1 cho company, 1 cho mình. Thì mình sẽ config trong .ssh/config như thế này:

#Company account (AT account)
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa

#My account (ngot-nuoc account)
Host github-ME
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_me

Đầu tiên git clone bằng SSH

git clone git@github.com:ngot-nuoc/ITracking.git

Sau khi clone repo về thì đầu tiên cần set user.name và user.email lại cho repo. Sau đó view .git/config của repo rồi seting lại [remote "origin"] cái URL là chỗ git@github-ME là OK

[user]
  name = Minh Loc
  email = minhloc.vhit@gmail.com
[remote "origin"]
  url = git@github-ME:ngot-nuoc/ITracking.git
  fetch = +refs/heads/*:refs/remotes/origin/*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment