linux同一台机子上用多个git 账号
Step 1 - Create a New SSH Key ssh-keygen -t rsa -C "your-email-address" Be careful that you don't over-write your existing key for your personal account. Instead,when prompted,save the file as id_rsa_COMPANY. In my case,I've saved the file to~/.ssh/id_rsa_nettuts. Step 2 - Attach the New Key Next,because we saved our key with a unique name,we need to tell SSH about it. Within the Terminal,type: ssh-add ~/.ssh/id_rsa_COMPANY. If successful,you'll see a response of "Identity Added." Step 3 - Create a Config File touch ~/.ssh/config If you're not comfortable with Vim,feel free to open it within any editor of your choice. Paste in the following snippet. #Default GitHub This is the default setup for pushing to our personal GitHub account. Notice that we're able to attach an identity file to the host. Let's add another one for the company account. Directly below the code above,add: Host github-COMPANY
Step 4 - Try it Out git init Login to your company account,create a new repository,give it a name of "Test," and then return to the Terminal and push your git repo to GitHub. git remote add origin git@github-COMPANY:Company/testing.git Note that,this time,rather than pushing to git@github.com,we're using the custom host that we create in the Return to GitHub,and you should now see your repository. Remember: When pushing to your personal account,proceed as you always have. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |