Work With Two Github Accounts Simultaneously
Three months ago, I came to Oushu Technology for an internship. Both studying and working used the Mac provided by the company. You get what you pay for; the Mac really is much easier to use than the 5000 RMB HP laptop I bought in 2015. So besides work, my study tasks and lab tasks also gradually migrated to the Mac. Now I have encountered a rather tricky problem: how to keep my work GitHub account from conflicting with my personal account while still using both conveniently.
After looking through related materials, I implemented the following solution.
Use the company account as the global default, and do nothing special where the company account is needed.
Handle personal repositories specially.
- Create an SSH key locally
- Configure the SSH public key in personal GitHub settings
- Modify
~/.ssh/config1
2
3
4
5# Personal github user
Host github.ys
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_personal_github - When cloning repositories, use the SSH link and replace
github.comwithgithub.ys - For existing repositories, change the
remoteitem in.git/config; the link is the same as in step 4 - Configure local commits.
1
2git config user.email yangsen758@foxmail.com
git config user.name YoungForest
To make hexo deploy automatically, change the repo link in Hexo’s _config.yml, similar to cloning.
1 | # Deployment |