Multiple git user in single device

亡梦爱人 提交于 2020-01-03 02:23:57

问题


I use my company laptop for company stuff but sometime I would also want to use it to code my own side project. Now my git is configured to use company's git account, how can I use multiple accounts in one device? Note that my company and my side project is using bitbucket too.

Or I should just create another user in mac, one for company stuff one for personal stuff?


回答1:


It depends on how you access the remote repo

  • https: make sure add your personal user account in the remote repo URL: https://me@bitbucket.org/me/myrepo.
    Then use a credential helper to cahce the credentials (login/password).
  • ssh: you can configure multiple private keys, one linked to a professional account, one linked to a personnal account, all referenced in ~/.ssh/config.
    See "MacOS Terminal: how to use a seccond ssh key?" as an example.

Make sure, within your personal repo, to set the right user.name/user.email

cd /my/repo
git config user.name myName
git config user.name myPersonal@Email.com

That does not influence the authentication, but matters in order for your commits to reflect "who" commit them.



来源:https://stackoverflow.com/questions/50304606/multiple-git-user-in-single-device

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!