โจทย์
ตอนนี้ผมมี account 2 อันที่ใช้ github.com
1. ของส่วนตัว
2. ของบริษัท
ปัญหาคือ ทั้ง 2 account ชี้ไปที่ github.com
ผมต้องการแยก
วิธีแก้ปัญหา
ต้องแก้ 2 ที่
1. แก้ที่ ~/.ssh/config ให้ตั้งชื่อ hostname ไม่ซ้ำ และใช้ User git เท่านั้น
2. แก้ที่ project คือ your-project/.git/config ให้ replace จาก
https://github.com/mynameiskreang/basic-golang.git เป็น
git@github_mynameiskreang:mynameiskreang/basic-golang.git


ถ้าอธิบายให้ลึกขึ้น ก็คือ การเปลี่ยน protocol จาก https เป็น git และกำหนด username

และถ้าถามว่าทำไมถ้าตา pattern ไม่เหมือน standard ก็เพราะ git มี package เป็นของตัวเอง
เช่น git clone https หรือ ssh
ref git protocol, stackoverflow
คำถามต่อมาคือ แล้วมันเกี่ยวกับ ssh อย่างไร ทำงานอย่างไร?
ปกติเราจะใช้คำสั่ง ssh Host เช่น ssh github_mynameiskreang หรือ ssh root@domain.com
ทีนี้ใช้คำสั่ง git fetch git@github_mynameiskreang:mynameiskreang/basic-golang.git
ตรง github_mynameiskreang ก็จะไป map กับใน ~/.ssh/config ให้เอง (ด้วยความสามารถ git protocol)

Refs
https://superuser.com/questions/366649/ssh-config-same-host-but-different-keys-and-usernames
https://stackoverflow.com/questions/33846856/what-exactly-is-the-git-protocol
https://git-scm.com/book/en/v2/Git-on-the-Server-The-Protocols#The-Git-Protocol