zoukankan      html  css  js  c++  java
  • 同一台机子上用多个git 账号

    We need to generate a unique SSH key for our second GitHub account.

    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.

    Next, login to your second GitHub account, browse to "Account Overview," and attach the new key, within the "SSH Public Keys" section. To retrieve the value of the key that you just created, return to the Terminal, and type: vim ~/.ssh/id_rsa_COMPANY.pub. Copy the entire string that is displayed, and paste this into the GitHub textarea. Feel free to give it any title you wish.

    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."

    We've done the bulk of the workload; but now we need a way to specify when we wish to push to our personal account, and when we should instead push to our company account. To do so, let's create a config file.

    If you're not comfortable with Vim, feel free to open it within any editor of your choice. Paste in the following snippet.

    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:

    This time, rather than setting the host to github.com, we've named it as github-COMPANY. The difference is that we're now attaching the new identity file that we created previously: id_rsa_COMPANY. Save the page and exit!

    It's time to see if our efforts were successful. Create a test directory, initialize git, and create your first commit.

    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.

    Note that, this time, rather than pushing to git@github.com, we're using the custom host that we create in the
    config file: git@github-COMPANY.

    Return to GitHub, and you should now see your repository. Remember:

    • When pushing to your personal account, proceed as you always have.
    • For your company account, make sure that you use git!github-COMPANY as the host.

    Be sure to refer to the screencast if you need a more visual overview of the steps above!

  • 相关阅读:
    Ant Design Pro:Layout 组件——嵌套布局
    React实战之将数据库返回的时间转换为几分钟前、几小时前、几天前的形式。
    React实战之Ant Design—Upload上传_附件上传
    React实战之60s倒计时按钮(发送短信验证按钮)
    map方法到底会不会改变原始数组?
    【React】react开发vscode插件推荐
    【React】React 工程的 VS Code 插件及配置
    【React】react新特性实例详解(memo、lazy、suspense、hooks)
    数组常用slice和splice的区别
    【React】react-beautiful-dnd 实现组件拖拽
  • 原文地址:https://www.cnblogs.com/BenWong/p/4268029.html
Copyright © 2011-2022 走看看